自定义 Grails 验证
我想检查以确保两个字段不相等,并且一个字段大于另一个字段。说yearBorn
和yearMarried
。它们不能相等,并且 yearMarried
必须大于 yearBorn
。
I would like to check to make sure two fields are not equal and one is greater then the other. Say yearBorn
and yearMarried
. They cannot be equal and yearMarried
must be greater then yearBorn
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 2 参数自定义验证器,该验证器可以访问正在验证的值和整个实例:
You can use a 2-parameter custom validator that has access to both the value being validated and the entire instance: