﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
17679	Error messages from field.validators never used if the ValidationError has a code matching an error message on the Field	Jonathan Buchanan	nobody	"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."	Bug	closed	Forms	dev	Normal	duplicate			Unreviewed	1	0	0	0	0	0
