static Object requiredIfStatusEqual(status) {
// return a closure that will perform the validation
return {value, paf ->
// if the status is equal, the field is not required
if(status != paf.status) { return true }
// if the status is not equal, the value must be populated
return value ? true : 'default.blank.message'
}
}
Then, call the method in the static constraints block
static constraints = {- Ben Hidalgo
status( inList:[DRAFT, SUBMITTED])
shortTitle( validator:requiredIfStatusEqual(SUBMITTED))
}
No comments:
Post a Comment