Grails 验证依赖于其他属性
使用 grails 执行此类操作的正确方法是什么:
class myDomainThing {
String description
MyOtherDomainThing otherThing
static constraints = {
description(nullable:if(otherThing))
otherThing(nullable:if(description))
}
}
所以我要么想要有一个指向 otherDomainThing 的链接,要么想要一个字符串描述。
What is the correct way to do something like this with grails:
class myDomainThing {
String description
MyOtherDomainThing otherThing
static constraints = {
description(nullable:if(otherThing))
otherThing(nullable:if(description))
}
}
So I either want there to be a link to the otherDomainThing or I want a String description.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须使用 Grails 自定义验证
验证器
You will have to use Grails custom validation using the
validator
您需要使用自定义验证器
,显然其中有一些伪代码围绕
otherthing
you'll need to use a custom validator
obviously some pseudocode in there around
otherthing