Files
pydantic/docs/examples/example2.py
T
Samuel Colvin c81ec9aeec add support for annotation only fields (#41)
* add support for annotation only fields, fix #34

* adding tests with mypy

* adding docs for mypy usage

* adding mypy failure test

* adding alias tests

* tweak mypy tests
2017-06-07 19:56:46 +01:00

31 lines
599 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",
"index": null,
"track": null
},
"signup_ts": {
"error_msg": "Invalid datetime format",
"error_type": "ValueError",
"index": null,
"track": "datetime"
}
}
"""