8000 Error context and message by Gr1N · Pull Request #183 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c1110f0
POC of error context and message
Gr1N May 26, 2018
8a25c51
Move type errors to the `errors.py` module; Change errors interface a…
Gr1N May 27, 2018
b14c7bd
Merge branch 'master' into errors-context
Gr1N May 27, 2018
f8e4478
Rename `.as_dict()` to `.dict()`
Gr1N May 27, 2018
9692994
Fix `PydanticErrorMixin` constructor
Gr1N May 27, 2018
4ab5e69
Rename `exceptions.py` to `error_wrappers.py`
Gr1N May 28, 2018
15cd4e1
Do not include nullable `ctx`
Gr1N May 28, 2018
ed6d84e
Fix tests
Gr1N May 28, 2018
9e2ed7f
Added `int_validator`; Added `IntegerError`
Gr1N May 28, 2018
6447783
Added `float_validator`; Added `FloatError`
Gr1N May 28, 2018
01a20e5
Get rid of `__mro__` in prior of `exc.code`
Gr1N May 28, 2018
ecb2ecc
Removed `min_number_size` and `max_number_size` from config (#174)
Gr1N May 28, 2018
a2cc0a9
Added `NumberMinSizeError` and `NumberMaxSizeError`
Gr1N May 28, 2018
ef07e61
Added `NoneIsNotAllowedError`
Gr1N May 28, 2018
04d72e9
Added `EnumError`
Gr1N May 29, 2018
bc3bed8
Added `path_validator`; Added `PathError`
Gr1N May 29, 2018
a677a7e
Added `DictError`
Gr1N May 30, 2018
89804fb
Added `ListError`
Gr1N May 30, 2018
9e82397
Added `TupleError`
Gr1N May 30, 2018
6c2da85
Added `SetError`
Gr1N May 30, 2018
45f49c1
Added `datetime` related errors
Gr1N May 30, 2018
95b710f
Added `bytes` and `str` related errors
Gr1N May 30, 2018
af3d24f
Added `SequenceError`
Gr1N May 30, 2018
c5c906e
Improved code coverage
Gr1N May 30, 2018
6e62458
Display error context in string representation of validation error
Gr1N May 30, 2018
9b726ee
Redefine error message templates using config
Gr1N May 30, 2018
446cc76
Review fixes
Gr1N May 31, 2018
81df1c2
Updated changelog
Gr1N May 31, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added ListError
  • Loading branch information
Gr1N committed May 30, 2018
commit 89804fba0dac97ed871e6ad4b7fccbeea19d687d
6 changes: 6 additions & 0 deletions pydantic/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'EnumError',
'IntegerError',
'FloatError',
'ListError',
'PathError',

'NumberMinSizeError',
Expand Down Expand Up @@ -94,6 +95,11 @@ class FloatError(PydanticTypeError):
msg_template = 'value is not a valid float'


class ListError(PydanticTypeError):
code = 'list'
msg_template = 'value is not a valid list'


class PathError(PydanticTypeError):
code = 'path'
msg_template = 'value is not a valid path'
Expand Down
8 changes: 7 additions & 1 deletion pydantic/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,13 @@ def dict_validator(v) -> dict:
def list_validator(v) -> list:
if isinstance(v, list):
return v
return list(v)

try:
v = list(v)
except TypeError as e:
raise errors.ListError() from e

return v


def tuple_validator(v) -> tuple:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ def test_list():
assert exc_info.value.flatten_errors() == [
{
'loc': ('b',),
'msg': '\'int\' object is not iterable',
'type': 'type_error',
'msg': 'value is not a valid list',
'type': 'type_error.list',
},
]

Expand Down
0