Files
pydantic/docs/examples/config.py
T
Nikita Grishko 3f53cb5980 Update documentation (#162) (#189)
* Update documentation (#162)

* More docs about error handling
2018-06-04 10:55:48 +01:00

23 lines
420 B
Python

from pydantic import BaseModel, ValidationError
class Model(BaseModel):
v: str
class Config:
max_anystr_length = 10
error_msg_templates = {
'value_error.any_str.max_length': 'max_length:{limit_value}',
}
try:
Model(v='x' * 20)
except ValidationError as e:
print(e)
"""
validation errors
v
max_length:10 (type=value_error.any_str.max_length; limit_value=10)
"""