Author: russellm Date: 2010-05-08 23:26:09 -0500 (Sat, 08 May 2010) New Revision: 13148
Modified: django/trunk/docs/ref/validators.txt Log: Fixed #13341 -- Clarified the arguments to RegexValidators. Thanks to DrMeers for the report, and David Fischer for the draft text. Modified: django/trunk/docs/ref/validators.txt =================================================================== --- django/trunk/docs/ref/validators.txt 2010-05-09 04:25:34 UTC (rev 13147) +++ django/trunk/docs/ref/validators.txt 2010-05-09 04:26:09 UTC (rev 13148) @@ -16,7 +16,7 @@ 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 @@ .. 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`` ---------------- -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.