diff options
| author | Jacob Rief <jacob.rief@gmail.com> | 2023-04-08 22:10:17 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-06-16 08:38:28 +0200 |
| commit | 1fe0b167af3611cca79e8a8092ee929312193c6f (patch) | |
| tree | bfdc7ee5dd09b1f194b7308932b6de46c2881374 /docs/ref | |
| parent | 549d6ffeb6d626b023acc40c3bb2093b4b25b3d6 (diff) | |
Fixed #34473 -- Fixed step validation for form fields with non-zero minimum value.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/forms/fields.txt | 12 | ||||
| -rw-r--r-- | docs/ref/validators.txt | 11 |
2 files changed, 18 insertions, 5 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index 4084ae78d5..aa0a7a8444 100644 --- a/docs/ref/forms/fields.txt +++ b/docs/ref/forms/fields.txt @@ -562,7 +562,9 @@ For each field, we describe the default widget used if you don't specify .. attribute:: step_size - Limit valid inputs to an integral multiple of ``step_size``. + Limit valid inputs to an integral multiple of ``step_size``. If + ``min_value`` is also provided, it's added as an offset to determine if + the step size matches. ``DurationField`` ----------------- @@ -695,7 +697,9 @@ For each field, we describe the default widget used if you don't specify .. attribute:: step_size - Limit valid inputs to an integral multiple of ``step_size``. + Limit valid inputs to an integral multiple of ``step_size``. If + ``min_value`` is also provided, it's added as an offset to determine if + the step size matches. ``GenericIPAddressField`` ------------------------- @@ -831,7 +835,9 @@ For each field, we describe the default widget used if you don't specify .. attribute:: step_size - Limit valid inputs to an integral multiple of ``step_size``. + Limit valid inputs to an integral multiple of ``step_size``. If + ``min_value`` is also provided, it's added as an offset to determine if + the step size matches. ``JSONField`` ------------- diff --git a/docs/ref/validators.txt b/docs/ref/validators.txt index a091d20dbb..8dd90e0e61 100644 --- a/docs/ref/validators.txt +++ b/docs/ref/validators.txt @@ -340,9 +340,16 @@ to, or in lieu of custom ``field.clean()`` methods. ``StepValueValidator`` ---------------------- -.. class:: StepValueValidator(limit_value, message=None) +.. class:: StepValueValidator(limit_value, message=None, offset=None) Raises a :exc:`~django.core.exceptions.ValidationError` with a code of ``'step_size'`` if ``value`` is not an integral multiple of ``limit_value``, which can be a float, integer or decimal value or a - callable. + callable. When ``offset`` is set, the validation occurs against + ``limit_value`` plus ``offset``. For example, for + ``StepValueValidator(3, offset=1.4)`` valid values include ``1.4``, + ``4.4``, ``7.4``, ``10.4``, and so on. + + .. versionchanged:: 5.0 + + The ``offset`` argument was added. |
