2
有没有办法编写一个自定义的验证器,根据字段值执行不同的验证?grails domain class validator +根据字段值设置唯一约束?
例如
class myModel{
A a;
B b;
String prop
static belongsTo:[m:myModel]
constraints{
prop(validator:{
val,obj->
if (obj.a== null){
unique:[b,prop]
}
else{
unique:[a,b,prop]
}
})
}
}
我很困惑这个问题。
在此先感谢
我太新来grails回答你的问题,但我确实发现这可能有助于其他堆栈溢出问题。 http://stackoverflow.com/questions/3447612/grails-custom-validation-query-inside-validation-check-what-happens-while-upd – nathan 2010-09-16 15:37:05