diff options
| author | Loic Bistuer <loic.bistuer@sixmedia.com> | 2013-10-22 00:33:57 +0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-10-21 14:54:52 -0400 |
| commit | e565e1332ddfbb44fe7e6139375e3c243af7398d (patch) | |
| tree | e435682dd384a2fa4aca78b378679c92076041f2 /django/core | |
| parent | 28b70425afb2fb8bcbec09d249e37fa786f8a155 (diff) | |
Fixed #21275 -- Fixed a serializer error when generating migrations for contrib.auth.
The migration serializer now looks for a deconstruct method on any object.
Diffstat (limited to 'django/core')
| -rw-r--r-- | django/core/validators.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/django/core/validators.py b/django/core/validators.py index 78716ccd40..796c57e4b0 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import re from django.core.exceptions import ValidationError +from django.utils.deconstruct import deconstructible from django.utils.translation import ugettext_lazy as _, ungettext_lazy from django.utils.encoding import force_text from django.utils.ipv6 import is_valid_ipv6_address @@ -14,6 +15,7 @@ from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit EMPTY_VALUES = (None, '', [], (), {}) +@deconstructible class RegexValidator(object): regex = '' message = _('Enter a valid value.') @@ -39,6 +41,7 @@ class RegexValidator(object): raise ValidationError(self.message, code=self.code) +@deconstructible class URLValidator(RegexValidator): regex = re.compile( r'^(?:http|ftp)s?://' # http:// or https:// @@ -77,6 +80,7 @@ def validate_integer(value): raise ValidationError(_('Enter a valid integer.'), code='invalid') +@deconstructible class EmailValidator(object): message = _('Enter a valid email address.') code = 'invalid' @@ -173,6 +177,7 @@ comma_separated_int_list_re = re.compile('^[\d,]+$') validate_comma_separated_integer_list = RegexValidator(comma_separated_int_list_re, _('Enter only digits separated by commas.'), 'invalid') +@deconstructible class BaseValidator(object): compare = lambda self, a, b: a is not b clean = lambda self, x: x @@ -189,18 +194,21 @@ class BaseValidator(object): raise ValidationError(self.message, code=self.code, params=params) +@deconstructible class MaxValueValidator(BaseValidator): compare = lambda self, a, b: a > b message = _('Ensure this value is less than or equal to %(limit_value)s.') code = 'max_value' +@deconstructible class MinValueValidator(BaseValidator): compare = lambda self, a, b: a < b message = _('Ensure this value is greater than or equal to %(limit_value)s.') code = 'min_value' +@deconstructible class MinLengthValidator(BaseValidator): compare = lambda self, a, b: a < b clean = lambda self, x: len(x) @@ -211,6 +219,7 @@ class MinLengthValidator(BaseValidator): code = 'min_length' +@deconstructible class MaxLengthValidator(BaseValidator): compare = lambda self, a, b: a > b clean = lambda self, x: len(x) |
