You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we only support a very loose validation. There is now a
standard HTML5 element with matching regex. This will add the ability
to set a `mode` on the email validator. The mode will change the
validation that is applied to the field as a whole.
These modes are:
* loose: The pattern from previous Symfony versions (default)
* strict: Strictly matching the RFC
* html5: The regex used for the HTML5 Element
Deprecates the `strict=true` parameter in favour of `mode='strict'`
public$message = 'This value is not a valid email address.';
35
49
public$checkMX = false;
36
50
public$checkHost = false;
51
+
52
+
/**
53
+
* @deprecated since version 3.4, to be removed in 4.0. Set mode to "strict" instead.
54
+
*/
37
55
public$strict;
56
+
public$mode;
57
+
58
+
publicfunction__construct($options = null)
59
+
{
60
+
if (is_array($options) && array_key_exists('strict', $options)) {
61
+
@trigger_error(sprintf('The \'strict\' property is deprecated since version 3.4 and will be removed in 4.0. Use \'mode\'=>"%s" instead.', self::VALIDATION_MODE_STRICT), E_USER_DEPRECATED);
62
+
}
63
+
64
+
if (is_array($options) && array_key_exists('mode', $options) && !in_array($options['mode'], self::$validationModes, true)) {
65
+
thrownew \InvalidArgumentException('The \'mode\' parameter value is not valid.');
@trigger_error(sprintf('Calling `new %s(%s)` is deprecated since version 3.4 and will be removed in 4.0, use `new %s("%s")` instead.', self::class, $defaultMode ? 'true' : 'false', self::class, $defaultMode ? Email::VALIDATION_MODE_STRICT : Email::VALIDATION_MODE_LOOSE), E_USER_DEPRECATED);
if (!in_array($defaultMode, Email::$validationModes, true)) {
57
+
thrownew \InvalidArgumentException('The "defaultMode" parameter value is not valid.');
58
+
}
59
+
60
+
$this->defaultMode = $defaultMode;
34
61
}
35
62
36
63
/**
@@ -52,11 +79,25 @@ public function validate($value, Constraint $constraint)
52
79
53
80
$value = (string) $value;
54
81
55
-
if (null === $constraint->strict) {
56
-
$constraint->strict = $this->isStrict;
82
+
if (null !== $constraint->strict) {
83
+
@trigger_error(sprintf('The %s::$strict property is deprecated since version 3.4 and will be removed in 4.0. Use %s::mode="%s" instead.', Email::class, Email::class, Email::VALIDATION_MODE_STRICT), E_USER_DEPRECATED);
* @expectedDeprecation Calling `new Symfony\Component\Validator\Constraints\EmailValidator(true)` is deprecated since version 3.4 and will be removed in 4.0, use `new Symfony\Component\Validator\Constraints\EmailValidator("strict")` instead.
* @expectedDeprecation The 'strict' property is deprecated since version 3.4 and will be removed in 4.0. Use 'mode'=>"strict" instead.
230
+
* @expectedDeprecation The Symfony\Component\Validator\Constraints\Email::$strict property is deprecated since version 3.4 and will be removed in 4.0. Use Symfony\Component\Validator\Constraints\Email::mode="strict" instead.
231
+
* @group legacy
232
+
*/
97
233
publicfunctiontestStrict()
98
234
{
99
235
$constraint = newEmail(array('strict' => true));
@@ -110,7 +246,7 @@ public function testStrictWithInvalidEmails($email)
0 commit comments