In Grails when using CommandObjects
or DomainClass
how can I restrict a constraint of an inherited property?
Say I have a parent class with non-null property payload
:
abstract class TextContentCommand extends ContentCommand {
String payload
static constraints = {
payload nullable: false
}
In the subclass I'd like to make the property stricter and set the max length:
class FacebookTextContentCommand extends TextContentCommand {
public static final int LENGTH_MAX = 4
static constraints = {
importFrom TextContentCommand
payload maxSize: LENGTH_MAX
}
}
This way is not working and when a longer string is provided the validation passes. My knowledge of Grails is very superficial. How can I restrict the inherited properties?