#36019: MinValueValidator and MaxValueValidator messages do not match compare
operators
-----------------------------------+--------------------------------------
     Reporter:  Samuel Nussbaumer  |                    Owner:  (none)
         Type:  Bug                |                   Status:  closed
    Component:  Core (Other)       |                  Version:  5.1
     Severity:  Normal             |               Resolution:  duplicate
     Keywords:                     |             Triage Stage:  Unreviewed
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  1                  |                    UI/UX:  1
-----------------------------------+--------------------------------------
Changes (by Sarah Boyce):

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

Comment:

 This appears to be a duplicate of #32037

 The logic is correct. I guess this is what is causing confusion
 {{{
 >>> from decimal import Decimal
 >>> Decimal("0.2") < 0.2
 True
 }}}
 And so...
 {{{
 >>> from django.core.validators import MaxValueValidator,
 MinValueValidator
 >>> from django import forms
 >>> field = forms.DecimalField(validators=[MaxValueValidator(3.0),
 MinValueValidator(Decimal("0.2"))])
 >>> field.clean(Decimal("0.2"))
 Decimal('0.2')
 >>> field = forms.DecimalField(validators=[MaxValueValidator(3.0),
 MinValueValidator(0.2)])
 >>> field.clean(Decimal("0.2"))
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "/path_to_venv/lib/python3.10/site-
 packages/django/forms/fields.py", line 206, in clean
     self.run_validators(value)
   File "/path_to_venv/site-packages/django/forms/fields.py", line 197, in
 run_validators
     raise ValidationError(errors)
 django.core.exceptions.ValidationError: ['Ensure this value is greater
 than or equal to 0.2.']
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36019#comment:2>
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/01070193d4865824-f98f9bda-392b-4054-b47a-79ec269daea6-000000%40eu-central-1.amazonses.com.

Reply via email to