I am a newbie in grails and groovy. I have a Project domain-class with start and end date. I want to put in a constraint specifying that the end date needs to be greater than the start date(and then further another child object of project needs to have its startdate and enddate validate with the parent Project's dates). Is this possible with the min constraint or do I have to put it elsewhere? Unique constraint does allow two properties to be linked that way, hoping min/max constraints allow that. I have tried
startDate(blank:false)
endDate(blank:false, min:'startDate')
It throws an error saying the property startDate is not available on Project
endDate
is defined as ajava.util.Date
. Is this correct? If not, please specify what it is and I'll update my answer accordingly. – Extensormin
can apply just fine toDate
values. However, I don't believe you can use a dynamic value (i.e. another field value) in your constraint definition formin
sinceconstraints
is a static closure. You could doendDate(min: new Date())
, though, with no problems. – Extensor