8000 [Validator] #18156 In "strict" mode, email validator inaccurately cla… · symfony/symfony-docs@732f970 · GitHub
[go: up one dir, main page]

Skip to content

Commit 732f970

Browse files
committed
[Validator] #18156 In "strict" mode, email validator inaccurately claims certain valid emails are invalid
1 parent d7724dd commit 732f970

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

reference/configuration/framework.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Configuration
9393
* :ref:`cache <reference-validation-cache>`
9494
* :ref:`enable_annotations <reference-validation-enable_annotations>`
9595
* `translation_domain`_
96+
* `email_profile`_
9697
* `strict_email`_
9798
* `annotations`_
9899
* :ref:`cache <reference-annotations-cache>`
@@ -1334,14 +1335,22 @@ translation_domain
13341335
The translation domain that is used when translating validation constraint
13351336
error messages.
13361337

1338+
email_profile
1339+
.............
1340+
1341+
**type**: ``string`` **default**: ``basic``
1342+
1343+
If this option is specified, the :doc:`/reference/constraints/Email`
1344+
constraint validator will default to the specified email validation profile.
1345+
See the linked page for more information.
1346+
13371347
strict_email
13381348
............
13391349

13401350
**type**: ``Boolean`` **default**: ``false``
13411351

1342-
If this option is enabled, the `egulias/email-validator`_ library will be
1343-
used by the :doc:`/reference/constraints/Email` constraint validator. Otherwise,
1344-
the validator uses a simple regular expression to validate email addresses.
1352+
DEPRECATED. If this option is enabled, the :doc:`/reference/constraints/Email`
1353+
constraint validator will default to the strict 'rfc-no-warn' profile.
13451354

13461355
annotations
13471356
~~~~~~~~~~~

reference/constraints/Email.rst

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ cast to a string before being validated.
77
+----------------+---------------------------------------------------------------------+
88
| Applies to | :ref:`property or method <validation-property-target>` |
99
+----------------+---------------------------------------------------------------------+
10-
| Options | - `strict`_ |
10+
| Options | - `profile`_ |
11+
| | - `strict`_ |
1112
| | - `message`_ |
1213
| | - `checkMX`_ |
1314
| | - `checkHost`_ |
@@ -91,14 +92,41 @@ Basic Usage
9192
Options
9293
-------
9394

95+
.. versionadded:: 3.1
96+
The ``profile`` option was added in Symfony 3.1
97+
98+
profile
99+
~~~~~~~
100+
101+
**type**: ``string`` **default**: ``basic``
102+
103+
This option is used to specify exactly which type of email validation should
104+
be performed. It can be set to one of the following values:
105+
106+
``basic``
107+
Validation will occur against a simple regular expression.
108+
``html5``
109+
Validation will occur against the regular expression defined in
110+
the `HTML5 spec`_.
111+
``rfc``
112+
The `egulias/email-validator`_ library will perform an RFC-compliant
113+
validation in non-strict mode. If any warning messages regarding
114+
unusual/deprecated email address features are raised during validation,
115+
they will not prevent an otherwise-valid email from being marked as
116+
invalid.
117+
``rfc-no-warn``
118+
The `egulias/email-validator`_ library will perform an RFC-compliant
119+
validation in strict mode. If any warning messages regarding
120+
unusual/deprecated email address features are raised during validation,
121+
the email address will be considered invalid.
122+
94123
strict
95124
~~~~~~
96125

97126
**type**: ``boolean`` **default**: ``false``
98127

99-
When false, the email will be validated against a simple regular expression.
100-
If true, then the `egulias/email-validator`_ library is required to perform
101-
an RFC compliant validation.
128+
DEPRECATED. When true, the email validator will use the strict
129+
'rfc-no-warn' profile.
102130

103131
message
104132
~~~~~~~
@@ -127,3 +155,5 @@ of the given email.
127155
.. include:: /reference/constraints/_payload-option.rst.inc
128156

129157
.. _egulias/email-validator: https://packagist.org/packages/egulias/email-validator
158+
159+
.. _HTML5 spec: https://www.w3.org/TR/html-markup/datatypes.html#form.data.emailaddress-def

0 commit comments

Comments
 (0)
0