diff options
| author | Claude Paroz <claude@2xlibre.net> | 2013-03-14 16:19:59 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-03-14 17:03:43 +0100 |
| commit | 2f121dfe635b3f497fe1fe03bc8eb97cdf5083b3 (patch) | |
| tree | d858b3ac2a6ee0beb52a079e98ac065dc0253834 /docs/ref/forms | |
| parent | 34d098665d9423c0b70add5b8c8231fff9d0f774 (diff) | |
Fixed #17051 -- Removed some 'invalid' field error messages
When the 'invalid' error message is set at field level, it masks
the error message raised by the validator, if any.
Diffstat (limited to 'docs/ref/forms')
| -rw-r--r-- | docs/ref/forms/validation.txt | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/docs/ref/forms/validation.txt b/docs/ref/forms/validation.txt index e89bce748f..978c985b55 100644 --- a/docs/ref/forms/validation.txt +++ b/docs/ref/forms/validation.txt @@ -181,24 +181,20 @@ the field's ``validators`` argument, or defined on the Field class itself with the ``default_validators`` attribute. Simple validators can be used to validate values inside the field, let's have -a look at Django's ``EmailField``:: +a look at Django's ``SlugField``:: - class EmailField(CharField): - default_error_messages = { - 'invalid': _('Enter a valid email address.'), - } - default_validators = [validators.validate_email] + class SlugField(CharField): + default_validators = [validators.validate_slug] -As you can see, ``EmailField`` is just a ``CharField`` with customized error -message and a validator that validates email addresses. This can also be done -on field definition so:: +As you can see, ``SlugField`` is just a ``CharField`` with a customized +validator that validates that submitted text obeys to some character rules. +This can also be done on field definition so:: - email = forms.EmailField() + slug = forms.SlugField() is equivalent to:: - email = forms.CharField(validators=[validators.validate_email], - error_messages={'invalid': _('Enter a valid email address.')}) + slug = forms.CharField(validators=[validators.validate_slug]) Form field default cleaning |
