Search code examples
grailsgroovy

Preferred way of writing constraints parameters in grails


Which way of writing constraints parameter is preferred in grails -
i)without first brackets

class User {
...
static constraints = {
    login size: 5..15, blank: false, unique: true
    password size: 5..15, blank: false
}
}

ii) with first brackets

class User {
...
static constraints = {
    login (size: 5..15, blank: false, unique: true)
    password (size: 5..15, blank: false)
}
}

Solution

  • It's a matter of style. Both are 100% valid and Grails/Groovy doesn't care. You should refer to your style guide for your code base. Which should be provided to you by your architect.