Is it possible to somehow create a feature with fields and constraints for these fields, and then create domain classes that implement this trait and collect constrained fields?
I have some code that looks something like this:
trait Shared {
String sharedField
static constraints = {
sharedField nullable: true
}
}
class ImplementingClass implements Shared {
...
}
Saving an instance of the implementation object using null sharedField is then rejected in violation of the constraint.
Can this be done? Is there an alternative syntax that is needed to use constraints and other GORM constructs in features implemented by domain objects?
source
share