|
Hello,
The following doesn't work:
public static class TestEmailValidation {
@Valid
@Email
private List<String> emails = Lists.newArrayList();
}
public static void main(String[] args) {
TestEmailValidation testEmailValidation = new TestEmailValidation();
testEmailValidation.emails.add("badEmailValue");
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
System.out.println(validator.validate(testEmailValidation));
}
I would expect Bean Validation to be able to validate collections of supported types (String, primitives, JodaTime dates...). For now we can only validate collection of annotated beans, but we can't annotate a String since we don't own this class...
It would be great to have a syntax to handle that, perhaps not the one I tried above but something like this:
@Valid({@Email})
private List<String> emails = Lists.newArrayList();
@Valid({@Future})
private List<LocalDate> nextBirthdays = Lists.newArrayList();
Or something similar
|