Hi all,
I'm busy working with Hibernate Validation (4.0.2.GA), and I have a small question about the error messages. Currently, I have a class like this:
Code:
class Company {
@NotEmpty
private String firstName;
// .. the rest here
I validate this using the following code:
Code:
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
return validator.validate(bean);
And I use this in my Wicket code to get the error message:
Code:
Set<ConstraintViolation<Company>> constraintViolations = WicketApplication.validate(company);
for (ConstraintViolation constraintViolation : constraintViolations) {
error(constraintViolation.getMessage());
}
However, the output in my UI is something like this:
may not be empty
My question is therefor: how do I figure out
what is empty? I'd rather not use the message property on the annotation, since I have to annotate around a 100 properties, and I wouldn't like to specify a 100 messages. I also cannot imagine this would be the way to go, but I haven't found the correct way yet, so if someone could help me out on this, that would be most appreciated!
Thanks,
Erik