# HG changeset patch # User Sandro Knauß # Date 1329878845 -3600 # Node ID ee4a6eb5a34b73ca679b4fa5eab69b506c8ea70d # Parent 6c76753f905650472f614426766e0ed1fbe10349 vInterger limits handles 0 correctly diff -r 6c76753f9056 -r ee4a6eb5a34b iro/validate.py --- a/iro/validate.py Sun Feb 19 17:49:23 2012 +0100 +++ b/iro/validate.py Wed Feb 22 03:47:25 2012 +0100 @@ -31,10 +31,10 @@ except TypeError: raise ValidateException(field=field) - if minv and ret < minv: + if minv is not None and ret < minv: raise ValidateException(field=field) - if maxv and ret > maxv: + if maxv is not None and ret > maxv: raise ValidateException(field=field) return ret diff -r 6c76753f9056 -r ee4a6eb5a34b tests/validate.py --- a/tests/validate.py Sun Feb 19 17:49:23 2012 +0100 +++ b/tests/validate.py Wed Feb 22 03:47:25 2012 +0100 @@ -40,6 +40,12 @@ with self.assertRaises(ValidateException): vInteger(3,None,minv=4) + with self.assertRaises(ValidateException): + vInteger(-1,None, minv=0) + + with self.assertRaises(ValidateException): + vInteger(1,None, maxv=0) + def testIntegerNoneAllowed(self): self.assertEqual(vInteger(None,None,none_allowed=True),None) self.assertEqual(vInteger('',None,none_allowed=True),None)