【发布时间】:2012-06-19 08:58:34
【问题描述】:
我有一个域类
class Store{
String name
Store hierarchy
Date dateCreated
Date lastUpdated
static hasMany=[storeRestrictions:StoreRestrictions]
boolean isBillable
boolean isConsignment
boolean isMassUploadPossible
static constraints = {
name(nullable:false,blank:false,maxSize:50,unique:true)
hierarchy(nullable:true,blank:true)
dateCreated()
lastUpdated()
isBillable()
isMassUploadPossible()
storeRestrictions(nullable:false)
}
}
有什么方法可以更改beforeInsert 和beforeUpdate 中的验证,例如,如果isConsignment 为真,那么storeRestrictions 可以变为nullable:true?
【问题讨论】:
-
不——你应该可以使用自定义验证器约束