tags:

views:

96

answers:

1

I'm hoping this just needs a new pair of eyes casting over it.

I have a school class

class School {
    String name

    static constraints = {
        name(maxLength:50,blank:false)
    }

    static hasMany = [pupils:Reviewer]

    String toString() {
        return name
    }
}

I have a School controller

class SchoolController {
    def scaffold = School
}

When I run the app and put a very long ( much longer than 50 than 50 char ) or even a blank name into my add school form, the constraints don't seem to be obeyed.

What am I missing?

Dave

+6  A: 

According to the Grails Validation Reference maxLength is deprecated..

Have you tried using maxSize instead?

j pimmel
That's done it thanks - at least it's limited the size of the input field to 50 characters. It seems that using maxLength not only doesn't work, it also stops any subsequent contraints from firing as well.Thanks for your help