Skip to content

[Validator] Html5 Email Validation #8487

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 1 commit into from
Dec 22, 2017
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions email/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ Problem: The Collector Object Is ``null``
The email collector is only available when the profiler is enabled and collects
information, as explained in :doc:`/testing/profiling`.

Problem: The Collector Doesn't Contain the E-Mail
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Problem: The Collector Doesn't Contain the Email
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If a redirection is performed after sending the email (for example when you send
an email after a form is processed and before redirecting to another page), make
Expand Down
33 changes: 27 additions & 6 deletions reference/constraints/Email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cast to a string before being validated.
+----------------+---------------------------------------------------------------------+
| Applies to | :ref:`property or method <validation-property-target>` |
+----------------+---------------------------------------------------------------------+
| Options | - `strict`_ |
| Options | - `mode`_ |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the strict option have been annotated as "deprecated in Symfony 4.1" rather than completely replaced?

| | - `message`_ |
| | - `checkMX`_ |
| | - `checkHost`_ |
Expand Down Expand Up @@ -91,14 +91,34 @@ Basic Usage
Options
-------

mode
~~~~

**type**: ``string`` **default**: ``loose``

This option is optional and defines the pattern the email address is validated against.
Valid values are:

* ``loose``
* ``strict``
* ``html5``

loose
.....

A simple regular expression. Allows all values with an "@" symbol in, and a "."
in the second host part of the email address.

strict
~~~~~~
......

**type**: ``boolean`` **default**: ``false``
Uses the `egulias/email-validator`_ library to perform an RFC compliant
validation. You will need to install that library to use this mode.

html5
.....

When false, the email will be validated against a simple regular expression.
If true, then the `egulias/email-validator`_ library is required to perform
an RFC compliant validation.
This matches the pattern used for the `HTML5 email input element`_.

message
~~~~~~~
Expand Down Expand Up @@ -127,3 +147,4 @@ of the given email.
.. include:: /reference/constraints/_payload-option.rst.inc

.. _egulias/email-validator: https://packagist.org/packages/egulias/email-validator
.. _HTML5 email input element: https://www.w3.org/TR/html5/sec-forms.html#email-state-typeemail