Does not pass given value when validating email address
See original GitHub issueSomewhat similar issue as #240, so I am keeping this short 😃
The documentation for the email-validator specifies the {1}
-argument as the given value, but it is not interpolated into the message.
var validator = ValidatorBuilder.<String>of()
.constraint((String email) -> email, "email",
l -> l.email().message("{0} must be a valid email address, but was '{1}'"))
.build();
var violation = validator.validate("@example.com").get(0);
assertThat(violation.message(), is("email must be a valid email address, but was '@example.com'"));
java.lang.AssertionError:
Expected: is "email must be a valid email address, but was '@example.com'"
but: was "email must be a valid email address, but was {1}"
Thought I’d also mention that the documentation for email-validator seems to be a little bit “off” as well, as it specifies the default message format as "{0}" must match {1}
, but it does not make much sense to say "email" must match @example.com
. However, the default message format seems to actually be "{0}" must be a valid email address
, which is all fine, though it does not include the given value.
Thanks!
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
regex - How can I validate an email address using a regular ...
If you want to validate that an email is correct, you have no choice than to send a confirmation email and have the...
Read more >4.1. Validate Email Addresses - Regular Expressions ...
The short answer to the validity problem is that you can't know whether john.doe@somewhere.com is an email address that can actually receive email...
Read more >Check if email address valid or not in Python - GeeksforGeeks
Method 1: Check for a valid email address using regular expression. This method either returns None (if the pattern doesn't match) or re....
Read more ><input type="email"> - HTML: HyperText Markup Language
The input will fail constraint validation if the length of the text value of the field is greater than maxlength UTF-16 code units...
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 >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
MessageFormat
is used to interpolate by default and the javadoc saysUse
"{0} must be a valid email address, but was ''{1}''"
insteadOh… I was not aware of that gotcha with
MessageFormat
. Then it works as expected! Thank you very much!