问题描述
我正在使用休眠验证器在我的应用程序中实现验证。我还使用了自定义注释和自定义验证器来满足业务验证需求。它工作正常,并且能够根据实现获取特定的错误消息。但是,现在我也想将错误代码(类似于下面的代码片段中给出的内容)连同错误消息一起返回给调用validate方法的方法的每个验证。
我已经阅读了有关休眠验证的文档,但找不到满足此要求的任何内容。有人可以帮我实现这种情况下的错误代码。
@ValidStateInCountry(code=006,message="Invalid state for given country")
@ValidZipInCountry(code=007,message="Invalid zip for given country")
public class Address {
@NotBlank(code=001,message="address line is mandatory")
private String addressLine;
@ValidCountry(code=002,message="Invalid Country name")
@NotBlank(code=003,message="Country name is mandatory")
private String country;
@NotBlank(code=004,message="state is mandatory")
private String state;
@NotBlank(code=005,message="zip is mandatory")
private String zipCode;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)