#30328: Callable passed to Min/Max validators breaks in the fields
-------------------------------------+-------------------------------------
               Reporter:  Harro      |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.2
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  1
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 in #29860 for django 2.2 the option was added to pass in a callable.

 I just upgraded to django 2.2 and found our custom max value validator for
 current year + 1 (which gave us a migration on the year change) and
 thought to replace it with the new mechanic.

 The result was the following error:
 ```
   File "<venv>/lib/python3.6/site-
 packages/django/db/models/fields/__init__.py", line 1799, in <genexpr>
     validator.limit_value <= max_value for validator in validators_)):
 ```

 So the field wants to check that the validator's max (and min) value lie
 within range of the Integer field which is not possible with the callable.

 The fix should be simple: Check if it's a callable and call it for the
 value.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30328>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.915dfbad1842cfc53515927b6865fcf2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to