Issue #3307736 by catch, alexpott: EmailValidator defaults to 'loose' mode which is deprecated in Symfony 6.2

merge-requests/2780/head
Alex Pott 2022-09-12 15:25:54 +01:00
parent 4c87cc0fa2
commit c3a7a32c5d
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
2 changed files with 26 additions and 1 deletions

View File

@ -28,7 +28,7 @@ class EmailConstraint extends Email {
* {@inheritdoc}
*/
public function validatedBy() {
return '\Symfony\Component\Validator\Constraints\EmailValidator';
return EmailValidator::class;
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Drupal\Core\Validation\Plugin\Validation\Constraint;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\EmailValidator as SymfonyEmailValidator;
/**
* Email constraint.
*
* Overrides the symfony validator to use the HTML 5 setting.
*
* @internal Exists only to override the constructor to avoid a deprecation
* in Symfony 6, and will be removed in drupal:11.0.0.
*/
final class EmailValidator extends SymfonyEmailValidator {
/**
* {@inheritdoc}
*/
public function __construct(string $defaultMode = Email::VALIDATION_MODE_HTML5) {
parent::__construct($defaultMode);
}
}