mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
3f53cb5980
* Update documentation (#162) * More docs about error handling
33 lines
514 B
Python
33 lines
514 B
Python
from pydantic import ValidationError
|
|
try:
|
|
User(signup_ts='broken', friends=[1, 2, 'not number'])
|
|
except ValidationError as e:
|
|
print(e.json())
|
|
|
|
"""
|
|
[
|
|
{
|
|
"loc": [
|
|
"id"
|
|
],
|
|
"msg": "field required",
|
|
"type": "value_error.missing"
|
|
},
|
|
{
|
|
"loc": [
|
|
"signup_ts"
|
|
],
|
|
"msg": "invalid datetime format",
|
|
"type": "type_error.datetime"
|
|
},
|
|
{
|
|
"loc": [
|
|
"friends",
|
|
2
|
|
],
|
|
"msg": "value is not a valid integer",
|
|
"type": "type_error.integer"
|
|
}
|
|
]
|
|
"""
|