I need a help from you. I'm creating a web service rest in java using jersey and hibernate. To validate the fields reported by the caller I used the JPA @Pattern annotation, as follows:
@XmlRootElement
public class Cfop {
@Pattern(regexp = "[0-9]+", message = "{cfop.idCfop.pattern}")
private String idCfop;
...
The message {cfop.idCfop.pattern} is defined in my ValidationMessages.properties file, as follows:
cfop.idCfop.pattern = Id ${validatedValue} inv\u00e1lido.
And on my Controller, I have:
@Path(Constante.CFOP_SERVICE_ENDPOINT)
public class CfopController {
private final CfopRepository repository = new CfopRepository();
@POST
@Consumes("application/json; charset=UTF-8")
@Produces("text/plain; charset=UTF-8")
public Response Cadastrar(@Valid Cfop cfop){
When I call my service via postman, it prints the right message, however it also shows a default message, which I do not want to be displayed, as follows:
Id 123s inválido. (path = CfopController.Cadastrar.arg0.idCfop, invalidValue = 123s)
You can suppress this message: (path = CfopController.Count.arg0.idCfop, invalidValue = 123s)?
Note: In my web.xml I have:
<init-param>
<param-ame>jersey.config.beanValidation.enableOutputValidationErrorEntity.server</param-name>
<param-value>true</param-value>
</init-param>