summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDejan Noveski <dr.mote@gmail.com>2014-03-13 12:23:12 +0100
committerErik Romijn <erik@erik.io>2014-03-21 11:12:36 +0100
commit4d0c5f61427a8e67552ee2d777fffbadc7aff3b2 (patch)
tree3a2c5393dbad0163f947cc2944e1f71f27ffd1a1 /docs
parentf2eea960e052db2d280e6dd016b0f8f23d5a8ef7 (diff)
Fixed #22255 -- Added support for specifying re flags in RegexValidator
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/validators.txt14
-rw-r--r--docs/releases/1.7.txt19
2 files changed, 28 insertions, 5 deletions
diff --git a/docs/ref/validators.txt b/docs/ref/validators.txt
index b3ae3c6d41..eb2e1d0d02 100644
--- a/docs/ref/validators.txt
+++ b/docs/ref/validators.txt
@@ -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])
diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt
index 934ad017c9..9df1b666d5 100644
--- a/docs/releases/1.7.txt
+++ b/docs/releases/1.7.txt
@@ -795,11 +795,15 @@ Tests
Validators
^^^^^^^^^^
-* :class:`~django.core.validators.RegexValidator` now accepts an optional
- Boolean :attr:`~django.core.validators.RegexValidator.inverse_match` argument
- which determines if the :exc:`~django.core.exceptions.ValidationError` should
+* :class:`~django.core.validators.RegexValidator` now accepts the optional
+ :attr:`~django.core.validators.RegexValidator.flags` and
+ Boolean :attr:`~django.core.validators.RegexValidator.inverse_match` arguments.
+ The :attr:`~django.core.validators.RegexValidator.inverse_match` attribute
+ determines if the :exc:`~django.core.exceptions.ValidationError` should
be raised when the regular expression pattern matches (``True``) or does not
- match (``False``, by default) the provided ``value``.
+ match (``False``, by default) the provided ``value``. The
+ :attr:`~django.core.validators.RegexValidator.flags` attribute sets the flags
+ used when compiling a regular expression string.
* :class:`~django.core.validators.URLValidator` now accepts an optional
``schemes`` argument which allows customization of the accepted URI schemes
@@ -1191,6 +1195,13 @@ Miscellaneous
a relation from the related object back to the content type for filtering,
ordering and other query operations.
+* When a model field's :attr:`~django.db.models.Field.validators` contains
+ a :class:`~django.core.validators.RegexValidator`, the regular expression
+ must now be passed as a regular expression string. You can no longer use a
+ pre-compiled regular expression in this case, as it is not serializable.
+ The :attr:`~django.core.validators.RegexValidator.flags` attribute was added
+ to :class:`~django.core.validators.RegexValidator` to simplify this change.
+
.. _deprecated-features-1.7:
Features deprecated in 1.7