mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
[1.7.x] Fixed #22255 -- Added support for specifying re flags in RegexValidator
Backport of 4d0c5f6142
from master.
This commit is contained in:
parent
cc8a800d0c
commit
b74ec85c1d
5 changed files with 61 additions and 8 deletions
|
@ -59,13 +59,16 @@ to, or in lieu of custom ``field.clean()`` methods.
|
|||
|
||||
``RegexValidator``
|
||||
------------------
|
||||
.. class:: RegexValidator([regex=None, message=None, code=None, inverse_match=None])
|
||||
.. class:: RegexValidator([regex=None, message=None, code=None, inverse_match=None, flags=0])
|
||||
|
||||
:param regex: If not ``None``, overrides :attr:`regex`. Can be a regular
|
||||
expression string or a pre-compiled regular expression.
|
||||
:param message: If not ``None``, overrides :attr:`.message`.
|
||||
:param code: If not ``None``, overrides :attr:`code`.
|
||||
:param inverse_match: If not ``None``, overrides :attr:`inverse_match`.
|
||||
:param flags: If not ``None``, overrides :attr:`flags`. In that case,
|
||||
:attr:`regex` must be a regular expression string, or
|
||||
:exc:`~exceptions.TypeError` is raised.
|
||||
|
||||
.. attribute:: regex
|
||||
|
||||
|
@ -93,6 +96,15 @@ to, or in lieu of custom ``field.clean()`` methods.
|
|||
|
||||
The match mode for :attr:`regex`. Defaults to ``False``.
|
||||
|
||||
.. attribute:: flags
|
||||
|
||||
.. versionadded:: 1.7
|
||||
|
||||
The flags used when compiling the regular expression string :attr:`regex`.
|
||||
If :attr:`regex` is a pre-compiled regular expression, and :attr:`flags` is overridden,
|
||||
:exc:`~exceptions.TypeError` is raised.
|
||||
Defaults to `0`.
|
||||
|
||||
``URLValidator``
|
||||
----------------
|
||||
.. class:: URLValidator([schemes=None, regex=None, message=None, code=None])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue