Skip to content
Browse files

Fixed #13341 -- Clarified default arguments to the RegexValidator. Th…

…anks to David Fischer for the report and patch.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent b82a5b9 commit 34587d8a2a5fd6cfd5fbe70b4b328a65d2407e0d @freakboy3742 freakboy3742 committed
Showing with 12 additions and 6 deletions.
  1. +7 −1 django/core/
  2. +5 −5 docs/ref/validators.txt
8 django/core/
@@ -21,16 +21,22 @@ class RegexValidator(object):
code = 'invalid'
def __init__(self, regex=None, message=None, code=None):
+ print 'test'
if regex is not None:
+ print 1
self.regex = regex
if message is not None:
+ print 2
self.message = message
if code is not None:
+ print 3
self.code = code
+ print 4
if isinstance(self.regex, basestring):
+ print 5
self.regex = re.compile(regex)
+ print 'REGEX', type(self.regex), self.regex
def __call__(self, value):
Validates that the input matches the regular expression.
10 docs/ref/validators.txt
@@ -59,13 +59,13 @@ methods.
-.. class:: RegexValidator(regex=None, message=None, code=None)
+.. class:: RegexValidator(regex, message=None, code=None)
-.. attribute:: regex=None
+.. attribute:: regex
-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.
+The regular expression pattern to search for the provided ``value``,
+or a pre-compiled regular expression. Raises a ``ValidationError``
+with ``message`` and ``code`` if no match is found.
.. attribute:: message=None

0 comments on commit 34587d8

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