From 0f2aca62f3043e98c12c6c624c28d51742ae9b97 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Thu, 30 Sep 2021 23:09:22 +0200 Subject: [PATCH] code style --- owrx/form/input/validator.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) + )