【发布时间】:2011-01-25 14:48:58
【问题描述】:
我有一个属于订阅的联系人类,我想在订阅属性上设置一个假设的只读约束,以便在脚手架模板中使用。
类的样子
class Contact {
static belongsTo = [subscription: Subscription]
static constraints = {
subscription(nullable: false, readonly: true) // hypothetic *readonly* constraint
name(blank: false)
email(blank: false, email: true)
}
Integer id
String name
String email
String description
}
我发现ConstrainedProperty.addMetaConstraint 方法“添加了一个非验证信息约束的元约束”。
如何在 Domain 类中调用它?
我如何获得元约束?
【问题讨论】:
标签: grails grails-orm