Search code examples
grailsgrails-orm

Grails 3.3.1 - Register new constraint


In previous versions of Grails, I could call:

grails.validation.ConstrainedProperty.registerNewConstraint(
                constraintName,
                constraintClass)

But now grails.validation.ConstrainedProperty is deprecated, and the class to use instead, grails.gorm.validation.ConstrainedProperty, does not have the method registerNewConstraint.

How can I register a new constraint in Grails 3.3.1?


Solution

  • Since grails 3.3.x you can't register constraints with the ConstraintedProperty the package doesn't matter. You should use the ConstraintRegistry. See the part Grails Validator and ConstrainedProperty API Deprecated of grails documentation