Bean Validation is a good option for checking objects, but how do I set up a REST API response (using RESTeasy) when thrown ConstraintViolationException?
For instance:
@POST
@Path("company")
@Consumes("application/json")
public void saveCompany(@Valid Company company) {
...
}
A request with invalid data will return an HTTP status code 400with the following body:
[PARAMETER]
[saveCompany.arg0.name]
[{company.name.size}]
[a]
Good, but not enough, I would like to normalize such errors in a JSON document.
How can I customize this behavior?
source
share