vInterger limits handles 0 correctly devel
authorSandro Knauß <knauss@netzguerilla.net>
Wed, 22 Feb 2012 03:47:25 +0100
branchdevel
changeset 178 ee4a6eb5a34b
parent 177 6c76753f9056
child 179 af65fcbd59d5
vInterger limits handles 0 correctly
iro/validate.py
tests/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
--- 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)