I'm using @Pattern to validate a field:
@Pattern(regexp = Patterns.ZIP_CODE, message="validation.ZIP_CODE")
private String zip;
In my messages.properties file I have this:
validation.ZIP_CODE=Must match NNNNN or NNNNN-NNNN
The javadocs seem to imply that it should look up the validation.ZIP_CODE message:
Returns:
The error message template.
Default:
"{javax.validation.constraints.Pattern.message}"
But instead I get the text:
validation.ZIP_CODE
Am I misunderstanding the javadoc, or am I implementing this incorrectly?
In order to use an internationalized message in a JEE 6 Pattern annotation, I believe you must wrap the property name in open/close curly braces.
@Pattern(regexp = Patterns.ZIP_CODE, message="{validation.ZIP_CODE}")
private String zip;