1
0
mirror of https://github.com/django/django.git synced 2025-10-25 14:46:09 +00:00

Fixed #26107 -- Added option to int_list_validator() to allow negative integers.

This commit is contained in:
Akshesh
2016-02-16 03:40:00 +05:30
committed by Tim Graham
parent b954ad0640
commit d58aaa24e3
4 changed files with 22 additions and 5 deletions

View File

@@ -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)