anti_social avatar 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:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.