#16617: URLField with min_length or max_length reports wrong length in
validation
messages
---------------------+----------------------------
Reporter: frasern | Owner: nobody
Type: Bug | Status: new
Milestone: | Component: Forms
Version: SVN | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------+----------------------------
Here's a simple example to illustrate the problem:
{{{
>>> from django.forms import URLField
>>> URLField(max_length=5).clean('example.com')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "django/forms/fields.py", line 153, in clean
self.run_validators(value)
File "django/forms/fields.py", line 142, in run_validators
raise ValidationError(errors)
ValidationError: [u'Ensure this value has at most 5 characters (it has
19).']
}}}
The entered value (''example.com'') is only 11 characters long, but the
validation message says that it is 19. This obviously has the potential
to cause confusion to the user.
The value 19 comes from the fact that length check is performed after the
value has been sanitised to ''!http://example.com/''.
A possible solution would be to add the sanitised value to the validation
message so that the user can better understand to what value the length
restriction actually applies. For example:
Ensure this value has at most 5 characters ("!http://example.com/" has
19).
Note that the same problem occurs with `min_length` as with `max_length`.
--
Ticket URL: <https://code.djangoproject.com/ticket/16617>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.