summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorHonza Král <honza.kral@gmail.com>2009-08-15 13:35:43 +0000
committerHonza Král <honza.kral@gmail.com>2009-08-15 13:35:43 +0000
commitf20e7fcdd22fe3a2181071af1f8460bb6c3d32f0 (patch)
tree1a917eca6c2c74ae8373e05ee89890e0b7de8dec /django
parent7a6a71dd0c6e04d46c0db55a46d97585e7edfe45 (diff)
[soc2009/model-validation] simple test for URLValidator, RegexValidator and BaseValidator
URL tests copied from tests/regressiontests/forms/fields.py git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@11460 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/core/validators.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/django/core/validators.py b/django/core/validators.py
index c5e7c23afb..4b9ab1f602 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -95,7 +95,7 @@ validate_comma_separated_integer_list = RegexValidator(comma_separated_int_list_
class BaseValidator(object):
- compare = lambda self, a, b: a is b
+ compare = lambda self, a, b: a is not b
clean = lambda self, x: x
message = _(u'Ensure this value is %(limit_value)s (it is %(show_value)s).')
code = 'limit_value'
@@ -105,11 +105,12 @@ class BaseValidator(object):
def __call__(self, value):
cleaned = self.clean(value)
+ params = {'limit_value': self.limit_value, 'show_value': cleaned}
if self.compare(cleaned, self.limit_value):
raise ValidationError(
- self.message,
+ self.message % params,
code=self.code,
- params={'limit_value': self.limit_value, 'show_value': cleaned}
+ params=params,
)
class MaxValueValidator(BaseValidator):