@ValidateWithMethod(methodName = "isValidPostalCode", parameterType = String.class)
private String _postalCode;
private boolean isValidPostalCode(String _postalCode) {
boolean status = false;
if (this.getTypeEnum() == 2) {
if ((this.getPostal_code() == null)|| (this.getPostal_code() == "")) {
status = true;
}
}
return status;
}我也在用Oval 1.7开发一个安卓应用程序。我试图用@ValidateWithMethod来验证一个实体类(属性验证),但是它不起作用,我猜它不能识别该方法,所有其他注释(如@MaxLength(value = 12) )都在工作。请帮帮我..。
发布于 2011-11-04 07:55:48
试着:
private boolean isValidPostalCode(String postalCode) {
if (postalCode == null || postalCode.isEmpty()) {
编辑:--您还应该向注释中添加ignoreIfNull = false。见http://oval.sourceforge.net/api/net/sf/oval/constraint/ValidateWithMethod.html#ignoreIfNull()
https://stackoverflow.com/questions/8006034
复制相似问题