Suppose a simple Grails domain class:
class Account {
String countryId;
String userName;
String areaId;
String password;
static constraints = {
...???...
}
}
It is required that user names are unique for a particular
countryId and
areaId, thus there must be a
unique contraint on three columns. And this is the constraints:
userName(unique: ['countryId', 'areaId'])
You can include as many other properties in the array that make up the
other properties that must be considered in the "unique" constraint on
the username.