简体   繁体   中英

Grails validators don't work

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

According to the Grails Validation Reference maxLength is deprecated..

Have you tried using maxSize instead?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM