code style
This commit is contained in:
parent
1e57fb4609
commit
0f2aca62f3
@ -13,6 +13,7 @@ class RequiredValidator(Validator):
|
|||||||
if value is None or value == "":
|
if value is None or value == "":
|
||||||
raise ValidationError(key, "Field is required")
|
raise ValidationError(key, "Field is required")
|
||||||
|
|
||||||
|
|
||||||
class RangeValidator(Validator):
|
class RangeValidator(Validator):
|
||||||
def __init__(self, minValue, maxValue):
|
def __init__(self, minValue, maxValue):
|
||||||
self.minValue = minValue
|
self.minValue = minValue
|
||||||
@ -23,4 +24,6 @@ class RangeValidator(Validator):
|
|||||||
return # Ignore empty values
|
return # Ignore empty values
|
||||||
n = float(value)
|
n = float(value)
|
||||||
if n < self.minValue or n > self.maxValue:
|
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)
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user