Here is what i want to be able to do with bean validation in my JPA entities :
@NotNull
, i would like to do @NotNull(message="keyInMyResourceBundleFile")
@NotNull(message="missing.value", params={"credit card"}) String creditCard;
It will be displayed something like this : "Missing required value for field credit card. In Indonesia, it'll be something like "Nilai harus di isi untuk Kartu Kredit. In this example, i cant hardcode the "credit card" because in Indonesia, it's "Kartu Kredit"ConstraintViolationException
, get the message, and process the resource bundle by my own code ?Please share your thoughts on this ?
Thank you !
Regarding 1 + 2
@NotNull(message="{keyInMyResourceBundleFile}")
Curly brackets are the indicator of a parameter substitution
Regarding 3
No idea what you are after. There is no params attribute for @NotNull. I guess you would do
@NotNull(message="{missing.credit.card}")
And of if you place it on another property you would call the key {missing.name}
Regarding 4
The ConstraintViolationException contains the set of *ConstraintViolation*s. Each ConstraintViolation contains the interpolated message as well as the message template. If you want to log it, do it ...