Fixed #32559 -- Added 'step_size’ to numeric form fields.

Co-authored-by: Jacob Rief <jacob.rief@uibk.ac.at>
This commit is contained in:
Kapil Bansal 2022-05-12 11:30:47 +02:00 committed by Carlton Gibson
parent 68da6b389c
commit 3a82b5f655
9 changed files with 137 additions and 19 deletions

View file

@ -1,4 +1,5 @@
import ipaddress
import math
import re
from pathlib import Path
from urllib.parse import urlsplit, urlunsplit
@ -401,6 +402,15 @@ class MinValueValidator(BaseValidator):
return a < b
@deconstructible
class StepValueValidator(BaseValidator):
message = _("Ensure this value is a multiple of step size %(limit_value)s.")
code = "step_size"
def compare(self, a, b):
return not math.isclose(math.remainder(a, b), 0, abs_tol=1e-9)
@deconstructible
class MinLengthValidator(BaseValidator):
message = ngettext_lazy(