diff options
| author | Akshesh <aksheshdoshi@gmail.com> | 2016-02-16 03:40:00 +0530 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-02-18 18:58:18 -0500 |
| commit | d58aaa24e31f10e56a7f05a4451cd06a3cc6e65d (patch) | |
| tree | 75b2a1d79cd855a4f8fce44212624f466cf9a7b9 /django | |
| parent | b954ad0640e1f246f60f31a07a567274c2f20751 (diff) | |
Fixed #26107 -- Added option to int_list_validator() to allow negative integers.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/validators.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/django/core/validators.py b/django/core/validators.py index dd18aee3cb..5e6265e507 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -283,8 +283,11 @@ def ip_address_validators(protocol, unpack_ipv4): % (protocol, list(ip_address_validator_map))) -def int_list_validator(sep=',', message=None, code='invalid'): - regexp = _lazy_re_compile('^\d+(?:%s\d+)*\Z' % re.escape(sep)) +def int_list_validator(sep=',', message=None, code='invalid', allow_negative=False): + regexp = _lazy_re_compile('^%(neg)s\d+(?:%(sep)s%(neg)s\d+)*\Z' % { + 'neg': '(-)?' if allow_negative else '', + 'sep': re.escape(sep), + }) return RegexValidator(regexp, message=message, code=code) |
