Skip to content
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
9 changes: 8 additions & 1 deletion colander_tools/strict.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ class Boolean(SchemaType):
On deserialize, accepts a boolean or a boolean represented as a string.
"""

def __init__(
self,
false_choices=('false', '0', 'disabled', 'untrue'),
):

self.false_choices = false_choices

def serialize(self, node, appstruct): # noqa
if appstruct is null:
return null
Expand All @@ -86,7 +93,7 @@ def deserialize(self, node, cstruct):
raise Invalid(node, _('${val} is not a boolean', mapping={'val': cstruct}))
result = result.lower()

if result in ('false', '0'):
if result in self.false_choices:
return False

return True
Expand Down