I’m trying to add a constraint to check that two attributes have different values.
Here is my case:
class Game {
static belongsTo = [ Team ]
Team teamHome
Team teamAway
}
What I’m trying to do is somenthig like:
static constraints = {
teamHome( notEqual: teamAway )
teamAway( notEqual: teamHome )
}
How can I solve this?
You can use a
validatorconstraint:The
valargument is theteamHomevalue, andobjis the object that is being validated, through which you can access theteamAwayproperty.