Skip to content

Commit

Permalink
improve exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ypankovych committed May 14, 2021
1 parent d08c4b7 commit 34789a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ person = Person(
)
# pankoff.exceptions.ValidationError: ["Attribute `backpack` should be an instance of `(<class 'list'>,)`", 'Attribute `backpack` length should be >= 5']
```
## Accessing the errors:
```python
try:
Person(...)
except ValidationError as exc:
print(exc.errors)
```
## combine() function
You can use `comdine(...)` to combine many validators.

Expand Down
3 changes: 2 additions & 1 deletion pankoff/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class ValidationError(ValueError):
pass
def __init__(self, errors):
self.errors = errors

0 comments on commit 34789a3

Please sign in to comment.