#31806: Make validators include the provided value in ValidationError
------------------------------+----------------------------------------
Reporter: Jon Dufresne | Owner: Jon Dufresne
Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------
Changes (by Jon Dufresne):
* status: closed => new
* resolution: needsinfo =>
Comment:
> Invalid form is redisplayed with errors in most (all?) of cases
This assumes the form system is used only for a narrow set of use cases
that involving HTML rendering. This is not always the case, especially in
projects I work on.
The form system has two major features: input validation and HTML
rendering. I often use the validation system without the HTML rendering.
When used in this context, yes, being able to include the provided value
in custom error messages is quite helpful. Sometimes this error is
displayed in a log other times as an alert. I opened this ticket as my
application has practical uses for it, not theoretical. I hit a wall when
trying to change an error message to meet an internal specification.
As a concrete example, my application allows uploading spreadsheets and
the data in those spreadsheets is validated using a Django form. This use
case has a history of support: see #24229. In the event of invalid data,
the precise error can't be displayed next to the originating value.
Providing the submitted value as context in the message helps the user
locate and correct it. For example `Email “blah” in cell A1 is not a valid
email address`.
Beyond my concrete use case, the code change is quite minimal (IMO) and
unobtrusive while providing more flexibility and control for users to
customize error messages. I think we should give users that power as it
comes with a low maintenance cost.
--
Ticket URL: <https://code.djangoproject.com/ticket/31806#comment:4>
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 on the web visit
https://groups.google.com/d/msgid/django-updates/067.1f47c580ab4609b5691fa6ec9e8e2a2d%40djangoproject.com.