How do one internationalize java bean validation?
Before internationalization i have (something like) the following validation error message:
email is not a valid email address (was some-nonexistant-user[at]invalid.email)
And according to : https://docs.oracle.com/javaee/6/tutorial/doc/gkahi.html one can create a ValidationMessages.properties file to internationalize the text
For example if i add the contents (keeping it in english for demonstrative purposes, alltough this should be in another language)
org.hibernate.validator.constraints.Email.message=is invalid email format
Now this creates the following validation error:
email is invalid email format (was some-nonexistant-user[at]invalid.email)
So this seems to only give me control of a small portion of the text, but how do i customize for example the was
part? And can have full control of the entire text? something like:
{property} is invalid (data = {value})
which would instead give me the output of
email is invalid (data = some-nonexistant-user[at]invalid.email)
If you can't do what you want through the localized properties files, you'll likely need to create your own MessageInterpolator.
See section 4.3.2 at http://beanvalidation.org/1.0/spec/#validationapi-message