Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catching all errors #14

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Catching all errors #14

wants to merge 18 commits into from

Conversation

gsakkis
Copy link
Contributor

@gsakkis gsakkis commented May 31, 2015

This PR addresses #11 by making possible to catch all validation errors of a given input instead of just the first one encountered. Any feedback from valideer users that would find this enhancement useful would be most welcome before merging it.

Summary:

  • A new Validator.full_validate() method is introduced, similar to validate(). The difference is that invalid inputs raise a MultipleValidationError exception, a new ValidationError subclass with an errors attribute that captures all individual errors in a (flat) list.
  • A new ContainerValidator abstract helper class is introduced to act as a base class of container-like validators that need to report multiple errors, without duplicating the logic between validate and full_validate or making the former less efficient than necessary by delegating to the latter.
  • All included container validators, namely HomogeneousSequence, HeterogeneousSequence, Mapping and Object now extend ContainerValidator and support reporting mutiple errors out of the box.
  • The custom compat.py module for Python 2/3 compatibility is replaced by six.
  • All error related classes and functions are moved to a separate errors.py module.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.21%) to 100.0% when pulling ae44ee1 on catch_all_errors into 133618c on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants