I want to add a global constraint to application.yml to make all fields in a domain class able to be null or blank. But I can't seem to get the syntax right. My domain class has about 30 fields and I want to avoid having to set constraints individually for every field. The examples on the Grails/Gorm site only show the old application.groovy syntax, below. I want to use application.yml instead:
grails.gorm.default.constraints = {
'*'(nullable: true, size: 1..20)
}
I've tried variations of the following in application.yml, but get runtime exceptions when starting my Grails app.
grails:
gorm:
default:
constraints: '*' (nullable: true, blank: true)
Below is an example of the runtime exception:
Caused by: java.lang.RuntimeException: Cannot load application metadata: while parsing a block mapping
in 'reader', line 137, column 9:
constraints: '*' nullable: true ...
^
expected <block end>, but found Scalar in 'reader', line 137, column 27:
constraints: '*' nullable: true, blank: true
Does anyone have a good example of the syntax for application.yml?
Create application.groovy
file in grails-app/conf/
and specify it there.