I validate in two ways - using spring validator for custom validation and javax.validation for quick and general
Spring does things neatly, where this code will go exactly to document with given locale and extract text required.
private Errors checkPasswordMatch(Person p, Errors errors) {
if (!p.getPassword().equals(p.getRepeatedPassword())) {
errors.rejectValue("password", "person.password.mismatch");
errors.rejectValue("repeatedPassword", "person.password.mismatch");
}
return errors;
}
Javax is less hassle, but there is no way to produce message in different languages.
@NotNull
@Size(min = 10, max = 10, message = "size must be 10 characters")
protected String birthDate;
How to advise javax to go to some GB.properties or US.properties or IT.properties file to extract messages same way spring does depending on user locale?