Skip to content

[Validator] Email - new allow-no-tld mode #17360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions reference/constraints/Email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,24 @@ This option defines the pattern used to validate the email address. Valid values
* ``loose`` uses a simple regular expression (just checks that at least one ``@``
character is present, etc.). This validation is too simple and it's recommended
to use one of the other modes instead;
* ``html5`` uses the same regular expression as the `HTML5 email input element`_,
making the backend validation consistent with the one provided by browsers;
* ``html5`` uses the regular expression of the `HTML5 email input element`_,
except it enforces a tld to be present.
* ``html5-allow-no-tld`` uses exactly the same regular expression as the `HTML5 email input element`_,
making the backend validation consistent with the one provided by browsers.
* ``strict`` validates the address according to `RFC 5322`_ using the
`egulias/email-validator`_ library (which is already installed when using
:doc:`Symfony Mailer </mailer>`; otherwise, you must install it separately).

.. versionadded:: 6.2

The ``html5-allow-no-tld`` mode was introduced in 6.2.

.. tip::

The possible values of this option are also defined as PHP constants of
:class:`Symfony\\Component\\Validator\\Constraints\\Email`
(e.g. ``Email::VALIDATION_MODE_STRICT``).


The default value used by this option is set in the
:ref:`framework.validation.email_validation_mode <reference-validation-email_validation_mode>`
configuration option.
Expand Down