#31306: Raise ValidationError on first failure
-------------------------------------+-------------------------------------
               Reporter:  Doug       |          Owner:  nobody
  Fultz                              |
                   Type:  New        |         Status:  new
  feature                            |
              Component:  Database   |        Version:  3.0
  layer (models, ORM)                |       Keywords:  feature request
               Severity:  Normal     |  validators
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Currently field validators are executed in order and any exceptions are
 collected before raising a single ValidationError for that field.
 
https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L600

 I have identified a use case where a validator may reach our to an
 external service or be very expensive to run, compared to other validators
 on the field.  It would help increase performance and decrease load on
 other services if there was an option for field validation to fail on the
 first exception and prevent subsequent validators from being executed.

 An example might be a validator that looks like
 {{{#!python
 ...
 validators = [RegexValidator(r'\w'), ExpensiveExists]
 }}}

 Where the regex validator is fast and runs locally while ExpensiveExists
 calls out to an external service.  In this case, we would want validation
 to fail on the regex and not call the expensive validation.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31306>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.91ca4b388632e571bfa0ac745c763a6f%40djangoproject.com.

Reply via email to