mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
b10566841e
* make errors less verbose, fix #71 * remove track too if null * update docs * better dict error, fix #74 * add history
28 lines
542 B
Python
28 lines
542 B
Python
from pydantic import ValidationError
|
|
try:
|
|
User(signup_ts='broken', friends=[1, 2, 'not number'])
|
|
except ValidationError as e:
|
|
print(e.json())
|
|
|
|
"""
|
|
{
|
|
"friends": [
|
|
{
|
|
"error_msg": "invalid literal for int() with base 10: 'not number'",
|
|
"error_type": "ValueError",
|
|
"index": 2,
|
|
"track": "int"
|
|
}
|
|
],
|
|
"id": {
|
|
"error_msg": "field required",
|
|
"error_type": "Missing"
|
|
},
|
|
"signup_ts": {
|
|
"error_msg": "Invalid datetime format",
|
|
"error_type": "ValueError",
|
|
"track": "datetime"
|
|
}
|
|
}
|
|
"""
|