Files
pydantic/docs/examples/example2.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

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"
}
]
"""