Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6eec07b

Browse filesBrowse files
committed
[Validator] Document the "normalizer" option
1 parent 7fcc58c commit 6eec07b
Copy full SHA for 6eec07b

File tree

8 files changed

+34
-0
lines changed
Filter options

8 files changed

+34
-0
lines changed

‎reference/constraints/Email.rst

Copy file name to clipboardExpand all lines: reference/constraints/Email.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Options - `checkHost`_
1111
- `groups`_
1212
- `message`_
1313
- `mode`_
14+
- `normalizer`_
1415
- `payload`_
1516
Class :class:`Symfony\\Component\\Validator\\Constraints\\Email`
1617
Validator :class:`Symfony\\Component\\Validator\\Constraints\\EmailValidator`
@@ -167,6 +168,7 @@ html5
167168

168169
This matches the pattern used for the `HTML5 email input element`_.
169170

171+
.. include:: /reference/constraints/_normalizer-option.rst.inc
170172
.. include:: /reference/constraints/_payload-option.rst.inc
171173

172174
.. _egulias/email-validator: https://packagist.org/packages/egulias/email-validator

‎reference/constraints/Ip.rst

Copy file name to clipboardExpand all lines: reference/constraints/Ip.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ IPv6 and many other combinations.
99
Applies to :ref:`property or method <validation-property-target>`
1010
Options - `groups`_
1111
- `message`_
12+
- `normalizer`_
1213
- `payload`_
1314
- `version`_
1415
Class :class:`Symfony\\Component\\Validator\\Constraints\\Ip`
@@ -96,6 +97,7 @@ Parameter Description
9697
``{{ value }}`` The current (invalid) value
9798
=============== ==============================================================
9899

100+
.. include:: /reference/constraints/_normalizer-option.rst.inc
99101
.. include:: /reference/constraints/_payload-option.rst.inc
100102

101103
version

‎reference/constraints/Length.rst

Copy file name to clipboardExpand all lines: reference/constraints/Length.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Options - `charset`_
1919
- `maxMessage`_
2020
- `min`_
2121
- `minMessage`_
22+
- `normalizer`_
2223
- `payload`_
2324
Class :class:`Symfony\\Component\\Validator\\Constraints\\Length`
2425
Validator :class:`Symfony\\Component\\Validator\\Constraints\\LengthValidator`
@@ -213,4 +214,5 @@ Parameter Description
213214
``{{ value }}`` The current (invalid) value
214215
================= ============================================================
215216

217+
.. include:: /reference/constraints/_normalizer-option.rst.inc
216218
.. include:: /reference/constraints/_payload-option.rst.inc

‎reference/constraints/NotBlank.rst

Copy file name to clipboardExpand all lines: reference/constraints/NotBlank.rst
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Applies to :ref:`property or method <validation-property-target>`
1111
Options - `allowNull`_
1212
- `groups`_
1313
- `message`_
14+
- `normalizer`_
1415
- `payload`_
1516
Class :class:`Symfony\\Component\\Validator\\Constraints\\NotBlank`
1617
Validator :class:`Symfony\\Component\\Validator\\Constraints\\NotBlankValidator`
@@ -110,4 +111,15 @@ Parameter Description
110111
``{{ value }}`` The current (invalid) value
111112
=============== ==============================================================
112113

114+
normalizer
115+
~~~~~~~~~~
116+
117+
**type**: ``string`` **default**: ``null``
118+
119+
If the given value is a ``string``, this option can be used to normalize it while
120+
checking if it is valid. A ``callable`` must be passed.
121+
122+
For example, you may want to use :phpfunction:`trim` to ignore leading and
123+
trailing whitespace during validation.
124+
113125
.. include:: /reference/constraints/_payload-option.rst.inc

‎reference/constraints/Regex.rst

Copy file name to clipboardExpand all lines: reference/constraints/Regex.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Options - `groups`_
1010
- `match`_
1111
- `message`_
1212
- `pattern`_
13+
- `normalizer`_
1314
- `payload`_
1415
Class :class:`Symfony\\Component\\Validator\\Constraints\\Regex`
1516
Validator :class:`Symfony\\Component\\Validator\\Constraints\\RegexValidator`
@@ -287,4 +288,5 @@ does *not* match this regular expression (via the :phpfunction:`preg_match`
287288
PHP function). However, if `match`_ is set to false, then validation will
288289
fail if the input string *does* match this pattern.
289290

291+
.. include:: /reference/constraints/_normalizer-option.rst.inc
290292
.. include:: /reference/constraints/_payload-option.rst.inc

‎reference/constraints/Url.rst

Copy file name to clipboardExpand all lines: reference/constraints/Url.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Options - `checkDNS`_
99
- `dnsMessage`_
1010
- `groups`_
1111
- `message`_
12+
- `normalizer`_
1213
- `payload`_
1314
- `protocols`_
1415
- `relativeProtocol`_
@@ -319,6 +320,7 @@ Parameter Description
319320
}
320321
}
321322
323+
.. include:: /reference/constraints/_normalizer-option.rst.inc
322324
.. include:: /reference/constraints/_payload-option.rst.inc
323325

324326
protocols

‎reference/constraints/Uuid.rst

Copy file name to clipboardExpand all lines: reference/constraints/Uuid.rst
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ UUID versions can also be restricted using a whitelist.
1010
Applies to :ref:`property or method <validation-property-target>`
1111
Options - `groups`_
1212
- `message`_
13+
- `normalizer`_
1314
- `payload`_
1415
- `strict`_
1516
- `versions`_
@@ -98,6 +99,7 @@ Parameter Description
9899
``{{ value }}`` The current (invalid) value
99100
=============== ==============================================================
100101

102+
.. include:: /reference/constraints/_normalizer-option.rst.inc
101103
.. include:: /reference/constraints/_payload-option.rst.inc
102104

103105
strict
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
normalizer
2+
~~~~~~~~~~
3+
4+
**type**: ``string`` **default**: ``null``
5+
6+
This option allows a ``callable`` to be passed in order to normalize the given
7+
value while checking if it is valid.
8+
9+
For example, you may want to use :phpfunction:`trim` to ignore leading and
10+
trailing whitespace during validation.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.