diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-05-09 04:26:09 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-05-09 04:26:09 +0000 |
| commit | 2f279ec5950a30dece20615759b28fecada55580 (patch) | |
| tree | 15c3d92ff4e0daf2bb2f267b402dfa74ab3fe02b /docs/ref/validators.txt | |
| parent | 3341f39f412fac95f42cf84e1f58a925b0e32bdc (diff) | |
Fixed #13341 -- Clarified the arguments to RegexValidators. Thanks to DrMeers for the report, and David Fischer for the draft text.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13148 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/ref/validators.txt')
| -rw-r--r-- | docs/ref/validators.txt | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/docs/ref/validators.txt b/docs/ref/validators.txt index 1576c8fc1b..b921f8cd3b 100644 --- a/docs/ref/validators.txt +++ b/docs/ref/validators.txt @@ -16,7 +16,7 @@ for re-using validation logic between different types of fields. For example, here's a validator that only allows even numbers:: from django.core.exceptions import ValidationError - + def validate_even(value): if value % 2 != 0: raise ValidationError(u'%s is not an even number' % value) @@ -63,16 +63,19 @@ methods. .. attribute:: regex=None -The regular expression to search for the provided ``value``. Raises a -``ValidationError`` if no match was found. +The regular expression pattern to search for the provided ``value``. Raises a +``ValidationError`` with ``message`` and ``code`` if no match is found. If +no regex is specified, an empty string is used. -.. attribute:: code='invalid' +.. attribute:: message=None -The error code to use if validation fails. Defaults to ``'invalid'``. +The error message used by ``ValidationError`` if validation fails. If no +``message`` is specified, a generic ``"Enter a valid value"`` message is used. -.. attribute:: message=None +.. attribute:: code=None -The error message to use if ``regex`` doesn't match the provided ``value``. +The error code used by ``ValidationError`` if validation fails. If ``code`` +is not specified, ``"invalid"`` is used. ``URLValidator`` ---------------- |
