mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
e7227db41a
* starting insert prints * working exec_script * remove prints, fix exec_examples.py * more cleanup of examples, better model printing * upgrade netlify runtime * extra docs deps * few more small tweaks
16 lines
391 B
Python
16 lines
391 B
Python
from datetime import datetime
|
|
from typing import List, Optional
|
|
from pydantic import BaseModel, NoneStr
|
|
|
|
class Model(BaseModel):
|
|
age: int
|
|
first_name = 'John'
|
|
last_name: NoneStr = None
|
|
signup_ts: Optional[datetime] = None
|
|
list_of_ints: List[int]
|
|
|
|
m = Model(age=42, list_of_ints=[1, '2', b'3'])
|
|
print(m.age)
|
|
Model()
|
|
# will raise a validation error for age and list_of_ints
|