EmailValidator doesn't pass on an empty string
See original GitHub issueVaadin 14.1.19. I have the following code:
binder.forField(new TextField()).withValidator(new EmailValidator()).bind("field");
However, the validator marks an empty TextField as invalid, effectively disabling the possibility to have an optional email.
Certainly I can hook a converter before the validator which converts empty string to null and vice versa (it’s required anyway because of TextField rejecting nulls), but I wonder whether EmailValidator should pass blank strings?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Symfony 2 Email Validator Null Value - php - Stack Overflow
Look at the source of the validator: if an empty string or null is passed, it does nothing. In other words, empty values...
Read more >How to verify that strings are in valid email format
The example defines an IsValidEmail method, which returns true if the string contains a valid email address and false if it doesn't but...
Read more >Built-in Validators — FluentValidation documentation
NotEmpty Validator¶. Ensures that the specified property is not null, an empty string or whitespace (or the default value for value types, e.g.,...
Read more >Testing Exceptions in PHPUnit - BackEndTea
We use the EmailValidator to make sure that the emails are only from our company. //Email.php final class Email { private function __ ......
Read more >Java email regex examples - Mkyong.com
isValid(email)); } // Valid email addresses static Stream<String> ... EmailValidator; public class EmailValidatorApache { //doesn't consider ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I suggest to overload
EmailValidator
CTOR with a boolean value which says whether an empty value should be accepted or not. That will keep binary compatibility and won’t require introducing a new class.