[Django] #34503: Missleading message in MinValueValidator and MaxValueValidator

30 views
Skip to first unread message

Django

unread,
Apr 19, 2023, 4:56:30 AM4/19/23
to django-...@googlegroups.com
#34503: Missleading message in MinValueValidator and MaxValueValidator
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
bartektrybala |
Type: Bug | Status: new
Component: Core | Version: 4.2
(Serialization) | Keywords: MaxValueValidator,
Severity: Normal | MinValueValidator, message, less or
Triage Stage: | equal
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Here is a message error for MaxValueValidator:
message = _("Ensure this value is less than or equal to %(limit_value)s.")

but compare method checks if a < b. So it's not accurate comparision or
message, It should checks a <= b, isn't it?
The same for MinValueValidator

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

Django

unread,
Apr 19, 2023, 5:03:36 AM4/19/23
to django-...@googlegroups.com
#34503: Missleading message in MinValueValidator and MaxValueValidator
-------------------------------------+-------------------------------------
Reporter: bartektrybala | Owner: nobody

Type: Bug | Status: new
Component: Core | Version: 4.2
(Serialization) |
Severity: Normal | Resolution:
Keywords: MaxValueValidator, | Triage Stage:
MinValueValidator, message, less | Unreviewed
or equal |

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

* easy: 0 => 1


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

Django

unread,
Apr 19, 2023, 5:05:36 AM4/19/23
to django-...@googlegroups.com
#34503: Missleading message in MinValueValidator and MaxValueValidator
-------------------------------------+-------------------------------------
Reporter: bartektrybala | Owner: nobody
Type: Bug | Status: closed

Component: Core | Version: 4.2
(Serialization) |
Severity: Normal | Resolution: invalid

Keywords: MaxValueValidator, | Triage Stage:
MinValueValidator, message, less | Unreviewed
or equal |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by David Sanders):

* status: new => closed
* resolution: => invalid


Comment:

Sorry I think you may have misread the code.

Here is MaxValueValidator:

{{{
class MaxValueValidator(BaseValidator):


message = _("Ensure this value is less than or equal to
%(limit_value)s.")

code = "max_value"

def compare(self, a, b):
return a > b
}}}

Here a is the cleaned value while b is the limit. If compare is True then
a ValidationError is raised. The inverse of this comparison is therefore
correct: cleaned value must be less than or equal to the limit.

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

Reply all
Reply to author
Forward
0 new messages