Skip to content

Commit

Permalink
Update types.py
Browse files Browse the repository at this point in the history
  • Loading branch information
pthegner authored Mar 12, 2020
1 parent 45c1be2 commit d31a63c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions flask_restful/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ def boolean(value):
if isinstance(value, bool):
return value

if isinstance(value, int):
return bool(value)

if not value:
raise ValueError("boolean type must be non-null")
value = value.lower()
if value in ('true', '1',):
if value in ('true', '1'):
return True
if value in ('false', '0',):
if value in ('false', '0'):
return False
raise ValueError("Invalid literal for boolean(): {}".format(value))

Expand Down

0 comments on commit d31a63c

Please sign in to comment.