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.
* status: new => closed
* resolution: => wontfix
Comment:
Thanks for this ticket, however you use case is quite niche, IMO. You can
always use a custom field and override `run_validators()`.
--
Ticket URL: <https://code.djangoproject.com/ticket/31306#comment:1>
Comment (by Adam (Chainz) Johnson):
It's also bad user experience to hide an error until others have been
fixed. Django's run-them-all behaviour is the most user friendly.
--
Ticket URL: <https://code.djangoproject.com/ticket/31306#comment:2>