I'm using javax.validation.constraints.AssertTrue annotation in a form object of a Spring MVC project (Spring Boot 1.4.2).
My class is similar to this:
public class CommandForm {
@NotEmpty
@Email
private String email;
// ...
@AssertTrue(message="{error.my.custom.message}")
public boolean isValid(){
// validate fields
}
}
Method isValid is invoked correctly and validation process works fine, but my custom error code is not resolved correctly.
I have a error.my.custom.message field in my message.properties file, but when validation fails I get the "{error.my.custom.message}" string as error message instead of the resolved message.
What's wrong with my code? Is this the right syntax to set a custom error code?