summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/core/validators.py8
-rw-r--r--docs/ref/validators.txt10
2 files changed, 12 insertions, 6 deletions
diff --git a/django/core/validators.py b/django/core/validators.py
index b1b82dbf0d..bcf7789c25 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -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.
diff --git a/docs/ref/validators.txt b/docs/ref/validators.txt
index b921f8cd3b..bbba84c7f9 100644
--- a/docs/ref/validators.txt
+++ b/docs/ref/validators.txt
@@ -59,13 +59,13 @@ methods.
``RegexValidator``
------------------
-.. 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