#20867: Allow Form.clean() to target specific fields when raising ValidationError. -----------------------------+-------------------- Reporter: loic84 | Owner: nobody Type: New feature | Status: new Component: Forms | Version: master Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 -----------------------------+-------------------- The goal would be to unlock the following API:
{{{ def clean(self): errors = {} if condition1: errors['field1'] = ValidationError('message1', code='code') if condition2: errors['field2'] = ValidationError('message2', code='code') raise ValidationError(errors) }}} Most of the groundwork has been done for #20199. We would need to document passing a `dict` to `ValidationError`, just like we already document passing a `list` in [https://docs.djangoproject.com/en/dev/ref/forms/validation/#raising- validationerror ref/forms/validation/#raising-validationerror]. This would probably deprecate or reduce the need for the pattern discussed in [https://docs.djangoproject.com/en/dev/ref/forms/validation/#form- subclasses-and-modifying-field-errors ref/forms/validation/#form- subclasses-and-modifying-field-errors]. Refs #20199 #16986. -- Ticket URL: <https://code.djangoproject.com/ticket/20867> 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/049.0897ae07109135c8d224d06eb2d62a3c%40djangoproject.com. For more options, visit https://groups.google.com/groups/opt_out.