Without seeing the rest of your Domain I can't be sure of the specifics but are missing something important. You are missing the reference to the instance being validated. When using custom validation there are two optional parameters being passed into your validation closure. One is the instance of the class being validated, the other is the value of the current property. So, given a domain such as this:
class MyPerson {
String name
String nickName
static constraints = {
name(nullable: false, blank: false)
nickName(validator: {val, obj ->
if (obj.name == val) return false // ensure the name and nickname do not equal one another
return true
})
}
}
So in the above example the custom validation ensures that the name and nick name do not match one another. Notice the use of obj.name
to reference another property of the instance. This is key to what you are attempting to do.
In your case your validation may look something like this:
static contraints ={
title validator: { val, obj ->
if (obj.title.getLanguage().equals(obj.summary.getLanguage())) println "same language"
}
}
Hope this helps.