Question

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???

Était-ce utile?

La solution

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)
    }   
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top