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:
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user