#36019: MinValueValidator and MaxValueValidator messages do not match compare
operators
-------------------------------------+-------------------------------------
     Reporter:  Samuel Nussbaumer    |                     Type:  Bug
       Status:  new                  |                Component:  Core
                                     |  (Other)
      Version:  5.1                  |                 Severity:  Normal
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  1
-------------------------------------+-------------------------------------
 Excerpt from
 [https://github.com/django/django/blob/main/django/core/validators.py
 /django/core/validators.py]:

 {{{
 @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


 @deconstructible
 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
 }}}

 The messages imply that the comparison between a and b would be a <= b or
 a >= b whereas in practice they only check if a is greater or lesser than
 b.

 Reprod:
 1. Define a form field with validators=[MaxValueValidator(3),
 MinValueValidator(0.2)]
 2. On the form, type in 0.2 and save -> ValidationError: Ensure this value
 is greater than or equal to 0.2.
 Expected behavior: The form should not raise any ValidationErrors
 (according to the error message)
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36019>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070193d42e1196-25151556-1730-49b7-9451-780d969a4005-000000%40eu-central-1.amazonses.com.

Reply via email to