[Django] #32037: MinValueValidator, MaxValueValidator comparison is not compatible with there messages

8 views
Skip to first unread message

Django

unread,
Sep 23, 2020, 12:31:53 PM9/23/20
to django-...@googlegroups.com
#32037: MinValueValidator, MaxValueValidator comparison is not compatible with
there messages
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
MishaGubsky |
Type: Bug | Status: new
Component: Core | Version: 3.1
(Other) | Keywords: MinValueValidator,
Severity: Normal | MaxValueValidator, greater than or
Triage Stage: | equal, less than or equal
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
The standard messages for MinValueValidator and MinLengthValidator don't
appropriate the logic.

{{{#!python
@deconstructible
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

class MinValueValidator(BaseValidator):
message = _('Ensure this value is greater than or equal to
%(limit_value)s.')
code = 'min_value'

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

According to MinValueValidator and MaxValueValidator are inherited by
other validators, the simplest way to fix this is to update the error
message.

As an improvement will be great to have the validators without strong
comparison.

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

Django

unread,
Sep 23, 2020, 12:53:29 PM9/23/20
to django-...@googlegroups.com
#32037: MinValueValidator, MaxValueValidator comparisons are not compatible with
there messages
-------------------------------------+-------------------------------------
Reporter: MishaGubsky | Owner: nobody
Type: Bug | Status: closed
Component: Core (Other) | Version: 3.1
Severity: Normal | Resolution: invalid
Keywords: MinValueValidator, | Triage Stage:
MaxValueValidator, greater than | Unreviewed
or equal, less than or equal |

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

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


Comment:

As far as I'm aware,
[https://github.com/django/django/blob/01974d7f7549b2dca2a729c3c1a1ea7d4585eb3a/django/core/validators.py#L342-L343
the code] is correct as is. You can check the
[https://github.com/django/django/blob/01974d7f7549b2dca2a729c3c1a1ea7d4585eb3a/tests/validators/tests.py#L189
tests].

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

Reply all
Reply to author
Forward
0 new messages