#17679: Error messages from field.validators never used if the ValidationError 
has
a code matching an error message on the Field
----------------------------+--------------------
     Reporter:  insin       |      Owner:  nobody
         Type:  Bug         |     Status:  new
    Component:  Forms       |    Version:  SVN
     Severity:  Normal      |   Keywords:
 Triage Stage:  Unreviewed  |  Has patch:  1
Easy pickings:  0           |      UI/UX:  0
----------------------------+--------------------
 Given the following field, I would have expected that validate_email's
 error message would haven been displayed:

 {{{
 >>> from django.conf import settings
 >>> settings.configure()
 >>> from django import forms
 >>> from django.core import validators
 >>> f = forms.CharField(validators=[validators.validate_email])
 >>> f.clean('@@@@@@')
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/home/insin/Virtualenvs/django-
 trunk/src/django/django/forms/fields.py", line 155, in clean
     self.run_validators(value)
   File "/home/insin/Virtualenvs/django-
 trunk/src/django/django/forms/fields.py", line 144, in run_validators
     raise ValidationError(errors)
 django.core.exceptions.ValidationError: [u'Enter a valid value.']
 >>> import django
 >>> django.get_version()
 '1.4a1'
 }}}

 The root issue is that many of the django.core.validators use the
 "invalid" error code, which is always going to be defined on the field as
 it's a default. I have a branch on !GitHub which has one approach to
 updating this behaviour - using the validators' own error messages unless
 the message code has been customised on the field instance. The tests
 demonstrate a use case extending RegexValidator, which was raised as an
 issue in my JavaScript port of django.forms:

 https://github.com/insin/django/compare/validators-error-messages

 Another approach would be to change the codes used by the OOTB validators
 away from 'invalid', as is already the case with BaseValidator and classes
 which extend it.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17679>
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.

Reply via email to