Skip to content

Commit

Permalink
Merge pull request #115 from Wolphin-project/master
Browse files Browse the repository at this point in the history
use full path in RequiredFieldValidationError
  • Loading branch information
jamesturk committed Oct 10, 2017
2 parents ae13e5d + 816d7cb commit 96cabe2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions validictory/tests/test_other.py
Expand Up @@ -63,6 +63,18 @@ def test(self):
self.fail("No Exception")


def test_deep_required_error():
schema = {'type': 'object', 'properties': {'foo': {'type': 'object',
'properties': {'bar': {'type': 'integer', 'required': 'true'}}}}}
data = {'foo': {'baz': 3}}
try:
validictory.validate(data, schema)
except validictory.validator.RequiredFieldValidationError as e:
estr = str(e)
assert 'foo' in estr
assert 'bar' in estr


def test_deep_error():
schema = {'type': 'object', 'properties': {'foo': {'type': 'object', 'properties':
{'bar': {'type': 'array', 'items':
Expand Down
2 changes: 1 addition & 1 deletion validictory/validator.py
Expand Up @@ -333,7 +333,7 @@ def validate_required(self, x, fieldname, schema, path, required):
''' Validates that the given field is present if required is True '''
# Make sure the field is present
if fieldname not in x and required:
self._error("Required field '{fieldname}' is missing", None, fieldname, path=path,
self._error("Required field '{fieldname}' is missing", None, path, path=path,
exctype=RequiredFieldValidationError)

def validate_blank(self, x, fieldname, schema, path, blank=False):
Expand Down

0 comments on commit 96cabe2

Please sign in to comment.