Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3924

How to control Symfony's RepeatedType validation sequence

$
0
0

I am using Symfony's RepeatedType for an email address on a registration form.

$builder->add('email',    RepeatedType::class,    ['invalid_message' => 'Confirm your email address',    ]);

I am also adding constraints to the property declaration itself:

/** * @var string|null * * @Assert\NotBlank * @Assert\Email(message="You must enter a valid email address") */private ?string $email = null; 

The problem is that Symfony runs the RepeatedType validation before it runs the property specific ones.

In other words, if you enter an incorrect email address it will first ensure that you entered that incorrect email address twice before telling you it's wrong.

Same applies to my password by the way - it asserts that you re-entered it correctly before telling you password strength requirements weren't met.

I know that I can control the sequence of validation groups but since RepeatedType isn't applied to the model itself I am unsure how to achieve this.


Viewing all articles
Browse latest Browse all 3924

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>