Skip to content

Commit

Permalink
[#2939] Boolean validator added
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Oct 3, 2012
1 parent 3175db3 commit c540a2e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ckan/logic/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def int_validator(value, context):
except (AttributeError, ValueError), e:
raise Invalid(_('Invalid integer'))

def boolean_validator(value, context):
if value.lower() in ['true', 'yes', 't', 'y', '1']:
return True
return False

def isodate(value, context):
if isinstance(value, datetime.datetime):
return value
Expand Down

0 comments on commit c540a2e

Please sign in to comment.