Reputation: 1505
I am developing a grails application, I have domain classes like Tip, TipTag. Concept is, For a Tip I should have only 5 TipTag.
class Tip {
String description
static hasMany = [tags:TipTag]
static constraints = {
description(nullable:false,size:50..500)
}
}
How to restrict this in grails?? Any other way of doing this???
Upvotes: 1
Views: 898
Reputation: 4697
The maxSize constraint should do the job for you:
class Tip {
String description
static hasMany = [tags:TipTag]
static constraints = {
description(nullable:false,size:50..500)
tags(maxSize: 5)
}
}
Upvotes: 3