Error messages from field.validators never used if the ValidationError has a code matching an error message on the Field
|Reported by:||insin||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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'
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.