https://github.com/adriangb/typeval
https://github.com/adriangb/typeval
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/adriangb/typeval
- Owner: adriangb
- License: mit
- Created: 2022-05-05T06:58:19.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-03T16:01:01.000Z (over 2 years ago)
- Last Synced: 2024-10-18T12:20:20.459Z (6 months ago)
- Language: Python
- Size: 82 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# typeval
A prototype for integrating annotated-types with pydantic-core.
This is purely for exploration, it is highly likely that this will not be maintained long term.
## Example
```python
from dataclasses import dataclass
from typing import Annotatedfrom annotated_types import Gt, Len
from typeval import ValidatorName = Annotated[str, Len(0)]
Age = Annotated[int, Gt(0)]Students = dict[Name, Age]
@dataclass
class Classroom:
teacher: Name
students: Studentsclassroom = Validator(Classroom).validate_python(
{
"teacher": "Foo Bar",
"students": {
"Fizz": 3,
"Buzz": 5,
}
}
)students = Validator(Students).validate_python(
{
"Fizz": 3,
"Buzz": 5,
}
)
```