Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 2f279ec5950a30dece20615759b28fecada55580 1 parent 3341f39
Russell Keith-Magee authored May 09, 2010

Showing 1 changed file with 10 additions and 7 deletions. Show diff stats Hide diff stats

  1. 17  docs/ref/validators.txt
17  docs/ref/validators.txt
@@ -16,7 +16,7 @@ for re-using validation logic between different types of fields.
16 16
 For example, here's a validator that only allows even numbers::
17 17
 
18 18
     from django.core.exceptions import ValidationError
19  
-    
  19
+
20 20
     def validate_even(value):
21 21
         if value % 2 != 0:
22 22
             raise ValidationError(u'%s is not an even number' % value)
@@ -63,16 +63,19 @@ methods.
63 63
 
64 64
 .. attribute:: regex=None
65 65
 
66  
-The regular expression to search for the provided ``value``. Raises a
67  
-``ValidationError`` if no match was found.
  66
+The regular expression pattern to search for the provided ``value``. Raises a
  67
+``ValidationError`` with ``message`` and ``code`` if no match is found. If
  68
+no regex is specified, an empty string is used.
68 69
 
69  
-.. attribute:: code='invalid'
  70
+.. attribute:: message=None
70 71
 
71  
-The error code to use if validation fails. Defaults to ``'invalid'``.
  72
+The error message used by ``ValidationError`` if validation fails. If no
  73
+``message`` is specified, a generic ``"Enter a valid value"`` message is used.
72 74
 
73  
-.. attribute:: message=None
  75
+.. attribute:: code=None
74 76
 
75  
-The error message to use if ``regex`` doesn't match the provided ``value``.
  77
+The error code used by ``ValidationError`` if validation fails. If ``code``
  78
+is not specified, ``"invalid"`` is used.
76 79
 
77 80
 ``URLValidator``
78 81
 ----------------

0 notes on commit 2f279ec

Please sign in to comment.
Something went wrong with that request. Please try again.