I am trying to validate a form using Spring with integrated JSR-303 validations with Hibernate implementation. I have a "confirm email" (emailConf
) field that I would like to confirm is equal to the email
field. I saw a post of someone doing it like this:
public class ContactInfoForm {
@NotEmpty
private String name;
@NotEmpty
@Email
private String email;
@Expression(value = "emailConf= email", applyIf = "emailConf is not blank")
private String emailConf;
...
}
However, this emailConf
validation is not working (i.e. no error occurs when the fields don't match). I've seen a couple tutorials that have shown similar annotations, but can't find them anymore or any documentation on how this works. Does anyone know a way to validate "confirm email/password" fields through annotation? I am currently using the alternative, which is to implement Validator
and validate the confirm fields in the validate method.