0
我目前正在使用grails约束。我有课,看起来像这样Grails:检查一个特定的属性是否有错误
@Validateable
class StudentBean{
def String name;
def String age;
def String address;
def List<ErrorBean> errors = [];
static constraints = {
age nullable : false, validator : { val, obj, errors->
if(val<10)
errors.rejectValue("age", "student.age.notQualified.message", [val] as Object[], "Student not qualified.");
}
}
}
现在,假设我宣布一个很大的制约,然后我打电话student.validate()
我如何知道一个特定的属性有错误?例如,我只想知道“年龄”属性是否有错误?