[Django] #34473: StepValueValidator does not take into account min_value

19 views
Skip to first unread message

Django

unread,
Apr 7, 2023, 8:09:10 AM4/7/23
to django-...@googlegroups.com
#34473: StepValueValidator does not take into account min_value
-----------------------------------------+------------------------
Reporter: James Meakin | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
If you define a number input with `<input type="number" min=1 step=2>`,
client side this will only allow positive odd numbers.

We could generate the same input in a Django form with
`IntegerField(min_value=1, step_size=2)` and `Field.localize` is `False`,
which would then use `MinValueValidator` and `StepValueValidator`.

We then get into a problem as `StepValueValidator` always uses `0` as the
base, so `step_size=2` only even numbers are allowed. This then conflicts
with the client side validation, and the user cannot submit any value for
the input.

I'm unsure if this is a bug or whether this is just a configuration
problem, apologies if so, but the behaviour does seem to me to conflict
with how min and step is handled by browsers.

--
Ticket URL: <https://code.djangoproject.com/ticket/34473>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 8, 2023, 8:41:58 AM4/8/23
to django-...@googlegroups.com
#34473: StepValueValidator does not take into account min_value
------------------------------+------------------------------------

Reporter: James Meakin | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* cc: Jacob Rief, Kapil Bansal (added)
* type: Uncategorized => Bug
* component: Uncategorized => Forms
* stage: Unreviewed => Accepted


Comment:

Thanks for the report! As far as I'm aware we should pass `min_value` to
the `StepValueValidator`. Bug in 3a82b5f655446f0ca89e3b6a92b100aa458f348f.

--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:1>

Django

unread,
Apr 8, 2023, 11:41:58 AM4/8/23
to django-...@googlegroups.com
#34473: StepValueValidator does not take into account min_value
------------------------------+------------------------------------
Reporter: James Meakin | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by Kapil Bansal):

Thanks for the report. I think this is a bug. We need to consider min
value also with step_size

--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:2>

Django

unread,
Apr 8, 2023, 3:00:08 PM4/8/23
to django-...@googlegroups.com
#34473: StepValueValidator does not take into account min_value
------------------------------+--------------------------------------
Reporter: James Meakin | Owner: Jacob Rief
Type: Bug | Status: assigned

Component: Forms | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Jacob Rief):

* owner: nobody => Jacob Rief
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:3>

Django

unread,
Apr 8, 2023, 5:38:40 PM4/8/23
to django-...@googlegroups.com
#34473: StepValueValidator does not take into account min_value
------------------------------+--------------------------------------
Reporter: James Meakin | Owner: Jacob Rief
Type: Bug | Status: assigned
Component: Forms | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------

Comment (by Jacob Rief):

There is a patch: https://github.com/django/django/pull/16742

will be fixed in Django-5.0

--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:4>

Django

unread,
Apr 10, 2023, 11:18:59 AM4/10/23
to django-...@googlegroups.com
#34473: StepValueValidator does not take into account min_value
------------------------------+--------------------------------------
Reporter: James Meakin | Owner: Jacob Rief
Type: Bug | Status: assigned
Component: Forms | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Sarah Boyce):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:5>

Django

unread,
Apr 11, 2023, 4:15:28 AM4/11/23
to django-...@googlegroups.com
#34473: StepValueValidator does not take into account min_value
------------------------------+--------------------------------------
Reporter: James Meakin | Owner: Jacob Rief
Type: Bug | Status: assigned
Component: Forms | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1
* needs_docs: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:6>

Django

unread,
May 30, 2023, 11:51:52 AM5/30/23
to django-...@googlegroups.com
#34473: StepValueValidator does not take into account min_value
------------------------------+--------------------------------------
Reporter: James Meakin | Owner: Jacob Rief
Type: Bug | Status: assigned
Component: Forms | Version: dev

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Jacob Rief):

* version: 4.1 => dev


Comment:

pull request has been fixed for dev branch

--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:7>

Django

unread,
May 30, 2023, 12:34:29 PM5/30/23
to django-...@googlegroups.com
#34473: StepValueValidator does not take into account min_value
------------------------------+--------------------------------------
Reporter: James Meakin | Owner: Jacob Rief
Type: Bug | Status: assigned
Component: Forms | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Natalia Bidart):

* needs_better_patch: 1 => 0
* needs_docs: 1 => 0


Comment:

Hello Jacob,

When the PR for this ticket is updated to the latest requests from
reviewers, ideally you should unset the ticket's flags "needs
documentation" and "patch needs improvement". That way, the PR will re-
appear in the list of branches needing re-review. I have unset these for
you now.

--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:8>

Django

unread,
Jun 16, 2023, 12:47:06 AM6/16/23
to django-...@googlegroups.com
#34473: StepValueValidator does not take into account min_value
-------------------------------------+-------------------------------------

Reporter: James Meakin | Owner: Jacob
| Rief
Type: Bug | Status: assigned
Component: Forms | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:9>

Django

unread,
Jun 16, 2023, 6:19:40 AM6/16/23
to django-...@googlegroups.com
#34473: StepValueValidator does not take into account min_value
-------------------------------------+-------------------------------------
Reporter: James Meakin | Owner: Jacob
| Rief
Type: Bug | Status: closed
Component: Forms | Version: dev
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"1fe0b167af3611cca79e8a8092ee929312193c6f" 1fe0b16]:
{{{
#!CommitTicketReference repository=""
revision="1fe0b167af3611cca79e8a8092ee929312193c6f"
Fixed #34473 -- Fixed step validation for form fields with non-zero
minimum value.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34473#comment:10>

Reply all
Reply to author
Forward
0 new messages