summaryrefslogtreecommitdiff
path: root/django/forms/fields.py
diff options
context:
space:
mode:
authorHonza Král <honza.kral@gmail.com>2009-08-15 13:33:57 +0000
committerHonza Král <honza.kral@gmail.com>2009-08-15 13:33:57 +0000
commit5ebafe3fb98ca99c7b7392087b899f1053d5cf5e (patch)
tree1879a8b8cb9a70dbf246c9f5765893b819de4920 /django/forms/fields.py
parent84c9cf16d36661f891673208ef8517881167881e (diff)
[soc2009/model-validation] use RegexValidator in RegexField
declarative definition prepared for RegexValidator children git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@11455 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms/fields.py')
-rw-r--r--django/forms/fields.py12
1 files changed, 1 insertions, 11 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py
index 8bf1df3f58..38ae2cec19 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -439,17 +439,7 @@ class RegexField(CharField):
if isinstance(regex, basestring):
regex = re.compile(regex)
self.regex = regex
-
- def validate(self, value):
- """
- Validates that the input matches the regular expression. Returns a
- Unicode object.
- """
- super(RegexField, self).validate(value)
- if value == u'':
- return value
- if not self.regex.search(value):
- raise ValidationError(self.error_messages['invalid'])
+ self.validators.append(validators.RegexValidator(regex=regex))
class EmailField(CharField):
default_error_messages = {