mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
92d7689271
* add construct method, fix #48 * adding copy method * adding pickle support, fix #40 * tweak copy and add fields copy test * adding docs for immutability, values and copy * add docs for pickle
20 lines
306 B
Python
20 lines
306 B
Python
from pydantic import BaseModel, ValidationError
|
|
|
|
|
|
class Model(BaseModel):
|
|
v: str
|
|
|
|
class Config:
|
|
max_anystr_length = 10
|
|
|
|
|
|
try:
|
|
Model(v='x' * 20)
|
|
except ValidationError as e:
|
|
print(e)
|
|
"""
|
|
1 error validating input
|
|
v:
|
|
length not in range 0 to 10 (error_type=ValueError track=str)
|
|
"""
|