mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
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
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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"
|
||||
}
|
||||
}
|
||||
"""
|
||||
Reference in New Issue
Block a user