@POST
@Path("")
@Consumes({"application/x-www-form-urlencoded"})
TokenDTO login(@ApiParam(value = "The id of the channel used", required = true ) @HeaderParam("channel") @NotEmpty(message = "email.notempty") String channel) throws Exception;
大家好,我正在尝试验证通道参数,所以它不为空。如果我将它解析为空,它只会抛出我:
{
"code": 26,
"message": "Validation Error: :NotEmpty",
"data": [
{
"type": "NotEmpty",
"property": "",
"value": null,
"inputType": "body",
"attributes": null
}
],
"source": "XXXX",
"type": "ValidationException",
"guid": "965ee91a-99a1-4ae5-b721-6415a80dad23"
}
您能告诉我如何自定义验证错误消息吗?
编辑:我看过很多文章描述我如何自定义“字段”验证的消息。但我想验证一个方法参数。