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

Tolerate whitebox testing custom rules with error handling #618

Open
wants to merge 1 commit into
base: 1.3.x
Choose a base branch
from
Open
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion cerberus/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def __init__(self, *args, **kwargs):

self.document = None
""" The document that is or was recently processed.
TODO: consider whether initializing with {} would be a better option
Type: any :term:`mapping` """
self._errors = errors.ErrorList()
""" The list of errors that were encountered since the last document
Expand Down Expand Up @@ -305,7 +306,7 @@ def _error(self, *args):
else:
constraint = rules_set[rule]

value = self.document.get(field)
value = self.document.get(field) if self.document else None

self.recent_error = errors.ValidationError(
document_path, schema_path, code, rule, constraint, value, info
Expand Down