mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
18 lines
322 B
Python
18 lines
322 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)
|