1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #24531 -- Improved CommaSeparatedIntegerField validation.

`','`, `'1,,1'`, `',1'` etc. are no longer considered as valid
comma-separated integer lists.
This commit is contained in:
Bertrand Bordage
2015-02-14 15:20:43 +01:00
committed by Tim Graham
parent f4cc0c40a8
commit 3e64f3d0fc
5 changed files with 49 additions and 17 deletions

View File

@@ -214,6 +214,16 @@ to, or in lieu of custom ``field.clean()`` methods.
A :class:`RegexValidator` instance that ensures a value is a
comma-separated list of integers.
``int_list_validator``
----------------------
.. function:: int_list_validator(sep=',', message=None, code='invalid')
.. versionadded:: 1.9
Returns a :class:`RegexValidator` instance that ensures a string
consists of integers separated by ``sep``.
``MaxValueValidator``
---------------------

View File

@@ -213,7 +213,8 @@ URLs
Validators
^^^^^^^^^^
* ...
* Added :func:`django.core.validators.int_list_validator` to generate
validators of strings containing integers separated with a custom character.
Backwards incompatible changes in 1.9
=====================================
@@ -321,6 +322,9 @@ Miscellaneous
that value to construct absolute URLs have been moved to CSS for easier
customization.
* ``CommaSeparatedIntegerField`` validation has been refined to forbid values
like ``','``, ``',1'``, and ``'1,,2'``.
.. _deprecated-features-1.9:
Features deprecated in 1.9