-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Email assert passes empty string #10357
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
Comments
@yuri-karkh thanks for reporting this. I know it may be confusing at first, but I've asked about this in the Symfony Slack chat and the community told me the reason why Symfony does this. If EmailValidator displays an error when you pass an empty string, the validator is doing two different things: validating the format of email address and making them mandatory (because if you pass So it's better to keep this as is. If you want to only validate email address, without requiring them, use EmailValidator. If you want to validate emails and require them (not allow empty strings or null values) then use EmailValidator and NotBlank together. I'm going to propose some changes in the docs about this. Thanks! |
thanks for the reply @javiereguiluz. Agree that it will be better to have some notes in docs about this. |
We're trying to improve this in #10407. |
Fixed by #10407. |
Uh oh!
There was an error while loading. Please reload this page.
passing empty string as an email passed validation. var_dump of the $validator->validate( $object ); is below.
Also found similar issue here:
#4244
I can confirm that if use together with NotBlank() constraint Email() constraint works as expected. So not very obvious behaviour of assertion.
The text was updated successfully, but these errors were encountered: