Stefan Kendall
Stefan Kendall

Reputation: 67802

Setting a constraint for all properties of a domain object?

Is there a way to set a constraint for all properties of a grails domain object?

I want to set nullable: true for a class, essentially.

Upvotes: 2

Views: 406

Answers (1)

Rob Hruska
Rob Hruska

Reputation: 120286

I don't think you can. From what I can find, your only options are:

  1. Specify the constraint per property in the static constraints closure on the domain class
  2. Use a shared constraint or default constraint, configured in Config.groovy

I dug around through DefaultConstraintEvaluator.groovy to see if there was some undocumented way to maybe use a class or property name in the grails.gorm.default.constraints configuration, but didn't find any.

Perhaps you could submit a JIRA feature request to allow configuring default constraints per-class (by adding to the existing default constraints DSL).

Upvotes: 2

Related Questions