I'm using the ValidationRulesServlet
to generate valdr JSON for my APIs. Currently the generated JSON looks like this:
{
"Person" : {
"firstName" : {
"size" : {
"min" : 2,
"message" : "{javax.validation.constraints.Size.message}",
"max" : 2147483647
},
"required" : {
"message" : "{javax.validation.constraints.NotNull.message}"
}
},
"lastName" : {
"size" : {
"min" : 2,
"message" : "{javax.validation.constraints.Size.message}",
"max" : 20
},
"required" : {
"message" : "{javax.validation.constraints.NotNull.message}"
}
}
}
}
I'm using Jersey for my REST services and I want the messages
in the above JSON to be replaced with values from ValidationMessages.properties
.
My ValidationMessages.properties
is located in classpath (src/main/resources
) and is used correctly by Jackson. This can be confirmed by calling a REST endpoint with an invalid value. Here is an example response:
[
{
"message": "Must be between 2 and 2147483647 characters",
"messageTemplate": "{javax.validation.constraints.Size.message}",
"path": "PersonServiceImpl.updatePerson.arg0.firstName",
"invalidValue": ""
}
]
The corresponding message in my ValidationMessages.properties
is
javax.validation.constraints.Size.message = Must be between {min} and {max} characters
How can I get the valdr JSON to output messages from ValidationMessages.properties
rather than e.g. {javax.validation.constraints.Size.message}
?