diff --git a/django/core/validators.py b/django/core/validators.py
index 458f419..efb0a41 100644
|
a
|
b
|
class BaseValidator(object):
|
| 196 | 196 | |
| 197 | 197 | def __call__(self, value): |
| 198 | 198 | cleaned = self.clean(value) |
| 199 | | params = {'limit_value': self.limit_value, 'show_value': cleaned} |
| | 199 | params = {'limit_value': self.limit_value, 'show_value': cleaned[:self.limit_value] if isinstance(cleaned, basestring) else cleaned} |
| 200 | 200 | if self.compare(cleaned, self.limit_value): |
| 201 | 201 | raise ValidationError( |
| 202 | 202 | self.message % params, |
| … |
… |
class MinValueValidator(BaseValidator):
|
| 215 | 215 | code = 'min_value' |
| 216 | 216 | |
| 217 | 217 | class MinLengthValidator(BaseValidator): |
| 218 | | compare = lambda self, a, b: a < b |
| 219 | | clean = lambda self, x: len(x) |
| 220 | | message = _(u'Ensure this value has at least %(limit_value)d characters (it has %(show_value)d).') |
| | 218 | compare = lambda self, a, b: len(a) < b |
| | 219 | message = _(u'Ensure this value has at least %(limit_value)d characters (%(show_value)s).') |
| 221 | 220 | code = 'min_length' |
| 222 | 221 | |
| 223 | 222 | class MaxLengthValidator(BaseValidator): |
| 224 | | compare = lambda self, a, b: a > b |
| 225 | | clean = lambda self, x: len(x) |
| 226 | | message = _(u'Ensure this value has at most %(limit_value)d characters (it has %(show_value)d).') |
| | 223 | compare = lambda self, a, b: len(a) > b |
| | 224 | message = _(u'Ensure this value has at most %(limit_value)d characters (%(show_value)s...).') |
| 227 | 225 | code = 'max_length' |
| 228 | 226 | |