Constraints provide Grails with a declarative DSL for defining validation rules, schema generation and CRUD generation meta data. For example, consider these

class User {

String username
String password
String email
int age

static constraints = {
username size: 5..15, blank: false, unique: true
password minSize: 6, blank: false
email email: true, blank: false
age min: 18
}
}

The above domain constraints define that username will be in range 5..15 and should be unique and in case of age it should be of min 18 etc.
Now If you don’t want to hard code min size of password then you can obtain the value of that property as

and update the min size constraint of property password on the fly as

constrainedProperty.setMinSize(20)

now onward constraint on min size will be 20.We can assert this as

assert minConstraint.getMinSize()==20

Related Package: org.codehaus.groovy.grails.validation
and class: ConstrainedProperty Class