[Django] #21120: documentation talks about validators but separates definition and usage

12 views
Skip to first unread message

Django

unread,
Sep 18, 2013, 12:07:25 PM9/18/13
to django-...@googlegroups.com
#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.

Django

unread,
Sep 18, 2013, 12:28:04 PM9/18/13
to django-...@googlegroups.com
#21120: documentation talks about validators but separates definition and usage
-------------------------------------+-------------------------------------
Reporter: nicolas@… | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version:
Component: Documentation | 1.6-beta-1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: => 0
* needs_docs: => 0
* type: Bug => Cleanup/optimization
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

Yes, I think at least linking to the
[https://docs.djangoproject.com/en/dev/ref/validators/ validators
reference guide] would be helpful. If you could submit a patch I'll be
happy to review and commit it.

--
Ticket URL: <https://code.djangoproject.com/ticket/21120#comment:1>

Django

unread,
Sep 22, 2013, 4:42:42 AM9/22/13
to django-...@googlegroups.com
#21120: documentation talks about validators but separates definition and usage
-------------------------------------+-------------------------------------
Reporter: nicolas@… | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version:
Component: Documentation | 1.6-beta-1
Severity: Normal | Resolution:
Keywords: afraid-to-commit | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by EvilDMP):

* cc: EvilDMP (added)
* keywords: => afraid-to-commit


--
Ticket URL: <https://code.djangoproject.com/ticket/21120#comment:2>

Django

unread,
Sep 23, 2013, 7:12:55 AM9/23/13
to django-...@googlegroups.com
#21120: documentation talks about validators but separates definition and usage
-------------------------------------+-------------------------------------
Reporter: nicolas@… | Owner:
Type: | benhuckvale
Cleanup/optimization | Status: assigned
Component: Documentation | Version:
Severity: Normal | 1.6-beta-1
Keywords: afraid-to-commit | Resolution:
Has patch: 0 | Triage Stage: Accepted
Needs tests: 0 | Needs documentation: 0
Easy pickings: 1 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by benhuckvale):

* owner: nobody => benhuckvale
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/21120#comment:3>

Django

unread,
Sep 23, 2013, 10:16:58 AM9/23/13
to django-...@googlegroups.com
#21120: documentation talks about validators but separates definition and usage
-------------------------------------+-------------------------------------
Reporter: nicolas@… | Owner:
Type: | benhuckvale
Cleanup/optimization | Status: assigned
Component: Documentation | Version:
Severity: Normal | 1.6-beta-1
Keywords: afraid-to-commit | Resolution:
Has patch: 0 | Triage Stage: Accepted
Needs tests: 0 | Needs documentation: 0
Easy pickings: 1 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by benhuckvale):

I made some changes along the lines suggested, including the link to the
validators reference guide.
Pull request is https://github.com/django/django/pull/1663.

--
Ticket URL: <https://code.djangoproject.com/ticket/21120#comment:4>

Django

unread,
Sep 23, 2013, 10:39:08 AM9/23/13
to django-...@googlegroups.com
#21120: documentation talks about validators but separates definition and usage
-------------------------------------+-------------------------------------
Reporter: nicolas@… | Owner:
Type: | benhuckvale
Cleanup/optimization | Status: closed

Component: Documentation | Version:
Severity: Normal | 1.6-beta-1
Keywords: afraid-to-commit | Resolution: fixed

Has patch: 0 | Triage Stage: Accepted
Needs tests: 0 | Needs documentation: 0
Easy pickings: 1 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"98e0453f00958af63b50e70990903eb6a04e1933"]:
{{{
#!CommitTicketReference repository=""
revision="98e0453f00958af63b50e70990903eb6a04e1933"
Fixed #21120 -- Added more explicit text on using validators and link to
writing validators.

Thanks nicolas at niconomicon.net for the suggestion.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21120#comment:5>

Django

unread,
Sep 23, 2013, 10:52:07 AM9/23/13
to django-...@googlegroups.com
#21120: documentation talks about validators but separates definition and usage
-------------------------------------+-------------------------------------
Reporter: nicolas@… | Owner:
Type: | benhuckvale
Cleanup/optimization | Status: closed
Component: Documentation | Version:
Severity: Normal | 1.6-beta-1
Keywords: afraid-to-commit | Resolution: fixed
Has patch: 0 | Triage Stage: Accepted
Needs tests: 0 | Needs documentation: 0
Easy pickings: 1 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"cdb56725d4424cc58147e2ffd4426511aa95775e"]:
{{{
#!CommitTicketReference repository=""
revision="cdb56725d4424cc58147e2ffd4426511aa95775e"
[1.6.x] Fixed #21120 -- Added more explicit text on using validators and
link to writing validators.

Thanks nicolas at niconomicon.net for the suggestion.

Backport of 98e0453f00 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21120#comment:6>

Django

unread,
Sep 23, 2013, 10:52:09 AM9/23/13
to django-...@googlegroups.com
#21120: documentation talks about validators but separates definition and usage
-------------------------------------+-------------------------------------
Reporter: nicolas@… | Owner:
Type: | benhuckvale
Cleanup/optimization | Status: closed
Component: Documentation | Version:
Severity: Normal | 1.6-beta-1
Keywords: afraid-to-commit | Resolution: fixed
Has patch: 0 | Triage Stage: Accepted
Needs tests: 0 | Needs documentation: 0
Easy pickings: 1 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"a722dfda93eafd6ff02b91f7a222eaccfc444ef4"]:
{{{
#!CommitTicketReference repository=""
revision="a722dfda93eafd6ff02b91f7a222eaccfc444ef4"
[1.5.x] Fixed #21120 -- Added more explicit text on using validators and
link to writing validators.

Thanks nicolas at niconomicon.net for the suggestion.

Backport of 98e0453f00 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21120#comment:7>

Reply all
Reply to author
Forward
0 new messages