Commits

anti_social committed 4508c2e

Range validators do not validate if data is None.

Comments (0)

Files changed (1)

wtforms/validators.py

 
     def __call__(self, form, field):
         data = field.data
-        if data is None or (self.min is not None and data < self.min) or \
+        if data is None:
+            return
+        if (self.min is not None and data < self.min) or \
             (self.max is not None and data > self.max):
             if self.message is None:
                 # we use %(min)s interpolation to support floats, None, and
 
     def __call__(self, form, field):
         data = field.data
+        if data is None:
+            return
         min = self.min() if callable(self.min) else self.min
         max = self.max() if callable(self.max) else self.max
-        if data is None or (min is not None and data < min) or \
+        if (min is not None and data < min) or \
             (max is not None and data > max):
             if self.message is None:
                 if max is None: