Skip to content

Commit

Permalink
adding handling for blank=True when validating enumerated field
Browse files Browse the repository at this point in the history
  • Loading branch information
boblannon committed Feb 18, 2015
1 parent 130ee29 commit d28dcfc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions validictory/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,9 @@ def validate_enum(self, x, fieldname, schema, path, options=None):
raise SchemaError("Enumeration {!r} for field '{}' must be a container".format(
options, fieldname))
if value not in options:
self._error("is not in the enumeration: {options!r}", value, fieldname,
options=options, path=path)
if not(value == '' and schema.get('blank', self.blank_by_default)):
self._error("is not in the enumeration: {options!r}", value, fieldname,
options=options, path=path)

def validate_title(self, x, fieldname, schema, path, title=None):
if not isinstance(title, (_str_type, type(None))):
Expand Down

0 comments on commit d28dcfc

Please sign in to comment.