diff --git a/owrx/form/input/validator.py b/owrx/form/input/validator.py index b9b87d1..1bf1caa 100644 --- a/owrx/form/input/validator.py +++ b/owrx/form/input/validator.py @@ -13,6 +13,7 @@ class RequiredValidator(Validator): if value is None or value == "": raise ValidationError(key, "Field is required") + class RangeValidator(Validator): def __init__(self, minValue, maxValue): self.minValue = minValue @@ -20,7 +21,9 @@ class RangeValidator(Validator): def validate(self, key, value): if value is None or value == "": - return # Ignore empty values + return # Ignore empty values n = float(value) if n < self.minValue or n > self.maxValue: - raise ValidationError(key, 'Value must be between %s and %s'%(self.minValue, self.maxValue)) + raise ValidationError( + key, "Value must be between {min} and {max}".format(min=self.minValue, max=self.maxValue) + )