mirror of
https://github.com/django/django.git
synced 2025-11-28 22:49:09 +00:00
Fixed #32559 -- Added 'step_size’ to numeric form fields.
Co-authored-by: Jacob Rief <jacob.rief@uibk.ac.at>
This commit is contained in:
parent
68da6b389c
commit
3a82b5f655
9 changed files with 137 additions and 19 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue