Skip to content

Commit

Permalink
Merge pull request #2 from jesselang/DjangoModelResource-IntegerArray…
Browse files Browse the repository at this point in the history
…Field

Allow list_n_or_more to validate empty lists.
  • Loading branch information
dlamotte committed Oct 9, 2015
2 parents 0bf8262 + f5d1b29 commit c22432a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions krankshaft/valid.py
Expand Up @@ -569,9 +569,9 @@ def list_n_or_more(validator, n):
Wrap a validator that also validates the returned list has one or more
members.
'''
if n < 1:
if n < 0:
raise KrankshaftError(
'list_n_or_more only accepts values >= 1, not %s' % n
'list_n_or_more only accepts values >= 0, not %s' % n
)

def list_n_or_more_validator(data, expect):
Expand Down
2 changes: 1 addition & 1 deletion tests/krankshaft/test_valid.py
Expand Up @@ -499,7 +499,7 @@ def test_list_n_or_more_invalid_data(self):
self.expect_raises(valid.list_n_or_more(valid.int, 1), ['a',2], errors={0: ["invalid literal for int() with base 10: 'a'"]})

def test_list_n_or_more_invalid_n(self):
self.assertRaises(valid.KrankshaftError, valid.list_n_or_more, valid.int, 0)
self.assertRaises(valid.KrankshaftError, valid.list_n_or_more, valid.int, -1)

def test_slug(self):
self.expect(valid.slug, 'HELLO WORLD', 'hello-world')
Expand Down

0 comments on commit c22432a

Please sign in to comment.