Skip to content

Commit

Permalink
Merge pull request keleshev#16 from Rogdham/empty-or
Browse files Browse the repository at this point in the history
Make empty Or raise SchemaError. Fixes keleshev#13.
  • Loading branch information
Vladimir Keleshev committed Apr 18, 2013
2 parents b17b7b2 + d8dc368 commit 43dbb1c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def validate(self, data):
class Or(And):

def validate(self, data):
x = None
x = SchemaError([], [])
for s in [Schema(s, error=self._error) for s in self._args]:
try:
return s.validate(data)
Expand Down
2 changes: 2 additions & 0 deletions test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def test_or():
assert Or(int, dict).validate(5) == 5
assert Or(int, dict).validate({}) == {}
with SE: Or(int, dict).validate('hai')
assert Or(int).validate(4)
with SE: Or().validate(2)


def test_validate_list():
Expand Down

0 comments on commit 43dbb1c

Please sign in to comment.