I am using bean validation to validate my entity,
it works fine according to different locales and it shows region-specific error messages, but I want to internationalize a field 'ContactNo' according to the region like my error messages @NotBlank(message="{contactNo.size}").
So how to achieve
@Pattern(regexp="(^$|[0-9]{10})")
private String contactNo;`
where the regexp value changes according to the region?
The the value for the
regexpattribute has to be constant i.e. it needs to be available at compile time. So, either it needs to be a string literal as you do now or externalized into astatic finalvariable.I guess what you need has to be implemented in a custom Bean Validation constraint.