Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下约束是不可靠的,因为new Date()只会评估一次,给您留下一个陈旧的最大日期。
new Date()
class Foo { Date date static constraints = { date max: new Date() } }
那么如何可靠地约束日期呢?
假设日期不能大于当前的验证日期:
static constraints = { date(validator: { val, obj -> val <= new Date() }) }
Grails验证器