diff --git a/reference/constraints/Email.rst b/reference/constraints/Email.rst index 41c0e76f24f..9cc865c66be 100644 --- a/reference/constraints/Email.rst +++ b/reference/constraints/Email.rst @@ -11,6 +11,7 @@ Options - `checkHost`_ - `groups`_ - `message`_ - `mode`_ + - `normalizer`_ - `payload`_ Class :class:`Symfony\\Component\\Validator\\Constraints\\Email` Validator :class:`Symfony\\Component\\Validator\\Constraints\\EmailValidator` @@ -167,6 +168,7 @@ html5 This matches the pattern used for the `HTML5 email input element`_. +.. include:: /reference/constraints/_normalizer-option.rst.inc .. include:: /reference/constraints/_payload-option.rst.inc .. _egulias/email-validator: https://packagist.org/packages/egulias/email-validator diff --git a/reference/constraints/Ip.rst b/reference/constraints/Ip.rst index fcbb4057ff4..f04a36105f4 100644 --- a/reference/constraints/Ip.rst +++ b/reference/constraints/Ip.rst @@ -9,6 +9,7 @@ IPv6 and many other combinations. Applies to :ref:`property or method ` Options - `groups`_ - `message`_ + - `normalizer`_ - `payload`_ - `version`_ Class :class:`Symfony\\Component\\Validator\\Constraints\\Ip` @@ -96,6 +97,7 @@ Parameter Description ``{{ value }}`` The current (invalid) value =============== ============================================================== +.. include:: /reference/constraints/_normalizer-option.rst.inc .. include:: /reference/constraints/_payload-option.rst.inc version diff --git a/reference/constraints/Length.rst b/reference/constraints/Length.rst index ea96d7efb64..c0947326333 100644 --- a/reference/constraints/Length.rst +++ b/reference/constraints/Length.rst @@ -19,6 +19,7 @@ Options - `charset`_ - `maxMessage`_ - `min`_ - `minMessage`_ + - `normalizer`_ - `payload`_ Class :class:`Symfony\\Component\\Validator\\Constraints\\Length` Validator :class:`Symfony\\Component\\Validator\\Constraints\\LengthValidator` @@ -213,4 +214,5 @@ Parameter Description ``{{ value }}`` The current (invalid) value ================= ============================================================ +.. include:: /reference/constraints/_normalizer-option.rst.inc .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/NotBlank.rst b/reference/constraints/NotBlank.rst index 1c465e7c334..3783df1c5d7 100644 --- a/reference/constraints/NotBlank.rst +++ b/reference/constraints/NotBlank.rst @@ -11,6 +11,7 @@ Applies to :ref:`property or method ` Options - `allowNull`_ - `groups`_ - `message`_ + - `normalizer`_ - `payload`_ Class :class:`Symfony\\Component\\Validator\\Constraints\\NotBlank` Validator :class:`Symfony\\Component\\Validator\\Constraints\\NotBlankValidator` @@ -110,4 +111,15 @@ Parameter Description ``{{ value }}`` The current (invalid) value =============== ============================================================== +normalizer +~~~~~~~~~~ + +**type**: ``string`` **default**: ``null`` + +If the given value is a ``string``, this option can be used to normalize it while +checking if it is valid. A ``callable`` must be passed. + +For example, you may want to use :phpfunction:`trim` to ignore leading and +trailing whitespace during validation. + .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Regex.rst b/reference/constraints/Regex.rst index 953bd8533e8..4363b8a78cb 100644 --- a/reference/constraints/Regex.rst +++ b/reference/constraints/Regex.rst @@ -10,6 +10,7 @@ Options - `groups`_ - `match`_ - `message`_ - `pattern`_ + - `normalizer`_ - `payload`_ Class :class:`Symfony\\Component\\Validator\\Constraints\\Regex` Validator :class:`Symfony\\Component\\Validator\\Constraints\\RegexValidator` @@ -287,4 +288,5 @@ does *not* match this regular expression (via the :phpfunction:`preg_match` PHP function). However, if `match`_ is set to false, then validation will fail if the input string *does* match this pattern. +.. include:: /reference/constraints/_normalizer-option.rst.inc .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index 2f41a47b01f..558545ac21a 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -9,6 +9,7 @@ Options - `checkDNS`_ - `dnsMessage`_ - `groups`_ - `message`_ + - `normalizer`_ - `payload`_ - `protocols`_ - `relativeProtocol`_ @@ -319,6 +320,7 @@ Parameter Description } } +.. include:: /reference/constraints/_normalizer-option.rst.inc .. include:: /reference/constraints/_payload-option.rst.inc protocols diff --git a/reference/constraints/Uuid.rst b/reference/constraints/Uuid.rst index 1c84756223f..386803ab2e8 100644 --- a/reference/constraints/Uuid.rst +++ b/reference/constraints/Uuid.rst @@ -10,6 +10,7 @@ UUID versions can also be restricted using a whitelist. Applies to :ref:`property or method ` Options - `groups`_ - `message`_ + - `normalizer`_ - `payload`_ - `strict`_ - `versions`_ @@ -98,6 +99,7 @@ Parameter Description ``{{ value }}`` The current (invalid) value =============== ============================================================== +.. include:: /reference/constraints/_normalizer-option.rst.inc .. include:: /reference/constraints/_payload-option.rst.inc strict diff --git a/reference/constraints/_normalizer-option.rst.inc b/reference/constraints/_normalizer-option.rst.inc new file mode 100644 index 00000000000..262d7e41177 --- /dev/null +++ b/reference/constraints/_normalizer-option.rst.inc @@ -0,0 +1,10 @@ +normalizer +~~~~~~~~~~ + +**type**: ``string`` **default**: ``null`` + +This option allows a ``callable`` to be passed in order to normalize the given +value while checking if it is valid. + +For example, you may want to use :phpfunction:`trim` to ignore leading and +trailing whitespace during validation.