#21120: documentation talks about validators but separates definition and usage
-------------------------------+------------------------
Reporter: nicolas@… | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.6-beta-1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------
The top of the page deine a validator, the answer, but not the section
about the validators.
This is at the top:
""" Validators are simple functions (or callables) that take a single
argument and raise ValidationError on invalid input. Validators are run
after the field’s to_python and validate methods have been called. """
This is the section about validators (middle of the page):
"""
Using validators
Django’s form (and model) fields support use of simple utility functions
and classes known as validators. These can be passed to a field’s
constructor, via 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 SlugField:
from django.forms import CharField
from django.core import validators
class SlugField(CharField):
default_validators = [validators.validate_slug]
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:
slug = forms.SlugField()
is equivalent to:
slug = forms.CharField(validators=[validators.validate_slug])
"""
I think a simple example of a validator would be a nice thing to add. Or
at least provide a link to the source code of the validator showcased.
This is from the 1.6 and (at the time), dev version too:
https://docs.djangoproject.com/en/1.6/ref/forms/validation/
https://docs.djangoproject.com/en/dev/ref/forms/validation/
--
Ticket URL: <https://code.djangoproject.com/ticket/21120>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.b5f6e74fa035bdaab8f4f42fad86588c%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.