user542103
user542103

Reputation: 265

Grails domain property nullable - true by default?

Regarding setting a domain class property to be nullable, as described here: https://docs.grails.org/3.3.10/ref/Constraints/nullable.html

Is there a way to make "nullable equals true" to be the default for all properties in all my Grails domain classes? As opposed to the default for nullable being false.

As an additional note, I also have the property grails.databinding.convertEmptyStringsToNull = false in my application.yml file.

I'm on Grails 3.3.10.

Upvotes: 0

Views: 684

Answers (1)

doelleri
doelleri

Reputation: 19682

You can define default constraints for all domain classes in grails-app/conf/application.groovy.

grails.gorm.default.constraints = {
    '*'(nullable: true)
}

See the Sharing Constraints section of the docs for more details.

Upvotes: 7

Related Questions