Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[EmailValidator] Unresolvable Deprecation #49258

Closed
@raziel057

Description

@raziel057

Symfony version(s) affected

6.2.6

Description

Using Symfony 6.2, I always get deprecation errors that seems not resolvable because of the check in __construct of EmailValidator. When a Email constraint is created with a specific mode, it's taken in the validate method of EmailValidator, not in the constructor. Then in my mind the deprecation should be moved in validate method.

Related commit: #46518

Other deprecation notices (3)

  3x: Since symfony/validator 6.2: The "loose" mode is deprecated. The default mode will be changed to "html5" in 7.0.
    3x in MailSenderControllerTest::testSendMailAction from PTC\AdminBundle\Tests\Controller

How to reproduce

Create a form using Email::VALIDATION_MODE_HTML5:

$form = $this->createFormBuilder($defaultData)
        ->add('email', EmailType::class, array(
            'label' => 'email',
            'constraints' => array(
                new NotBlank(), 
                new Email(['mode' => Email::VALIDATION_MODE_HTML5])
            ),
            'attr' => array('maxlength' => '255'),
        ))
        ->getForm();

In the profiler I can see that the Email constraint is created with right mode but the related EmailValidator is not.

image

Possible Solution

Move the deprecation from __construct to validate method.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions