aidanskinner committed 60c627d

validators.DataRequired: allow 0, 0.0 as valid values

Int or Float fields should allow zero as a valid entry,
but not empty

Comments (0)

Files changed (2)


         self.assertEqual(len(f.errors), 1)
         self.assertRaises(StopValidation, required(), self.form, f)
         self.assertEqual(len(f.errors), 0)
+        f = DummyField(0)
+        required()(self.form, f)
+        self.assertEqual(len(f.errors), 0)
     def test_optional(self):
         self.assertEqual(optional()(self.form, DummyField('foobar', raw_data=['foobar'])), None)


         self.message = message
     def __call__(self, form, field):
-        if not or isinstance(, basestring) and not
+        if is None or isinstance(, basestring) and not
             if self.message is None:
                 self.message = field.gettext(u'This field is required.')