Source

django-model-validators / model_validators / validators.py

Diff from to

model_validators/validators.py

         file_extension = splitext(value.name)[-1][1:].lower()
         if file_extension not in self.file_extensions:
             raise ValidationError(u'File type %s not allowed.' % file_extension, code='invalid')
+
+
+class NumericRangeValidator(object):
+    def __init__(self, min_value, max_value):
+        assert(min_value <= max_value)
+        self.min_value = min_value
+        self.max_value = max_value
+
+    def __call__(self, value):
+        if value < self.min_value or value > self.max_value:
+            raise ValidationError(u'Value is out of range [%s - %s].' % (self.min_value, self.max_value))