I just did a quick audit of our project. We have 238 command classes and only about 20% of them have a constraints block at all.
I do agree that the default should hold regardless of whether or not a constraint is provided, for instance:
static constraints = {
foo(minSize: 10)
}
should NOT change minSize to nullable: false (that just seems like a side effect).
Now, when using importFrom() on a domain object, that is where the problem comes in. Because the domain objects have the opposite behavior, you don't really get a proper import for the implicitly null properties on the domain object. You end up having to repeat yourself for the nullable: false properties or put explicit nullable: false entries into the domain object.
My first choice would be that when using importFrom() the default behavior mimic that of the domain class and essentially do what it's doing at them moment in 2.4.0. Otherwise, the default behavior of a command object should be nullable: true (even in cases where a constraint is provided such as minSize, etc.).
My second choice would be a config option for default parameters like you can do with domain classes:
grails.gorm.default.constraints = {
'*'(nullable: true, size: 1..20)
}
So something like:
grails.validateable.default.constraints = { '*'(nullable: true)
}
would give us the 2.3.x behavior including the (annoying) behavior that adding ANY constraint effectively removes all of the defaults.
-Aaron