简体   繁体   English

Grails验证器不起作用

[英]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. 当我运行应用程序并在我的添加学校表单中放置一个非常长(超过50个字符50)甚至一个空白名称时,似乎没有遵守约束。

What am I missing? 我错过了什么?

Dave 戴夫

According to the Grails Validation Reference maxLength is deprecated.. 根据Grails验证参考, maxLength已被弃用..

Have you tried using maxSize instead? 您是否尝试过使用maxSize?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Grails:findAllWhere排序/最大值/偏移量运算符不起作用 - Grails: findAllWhere sort/max/offset operator don't work Spring Cloud Angel.SR4和Grails 3.0.9无法正常工作 - Spring Cloud Angel.SR4 And Grails 3.0.9 Don't Work 域中的日期字段和g:textField标记在Grails中不起作用 - Date field in domain and g:textField tag don't work in Grails 为什么Grails自动时间戳记字段在Oracle中不能始终如一地工作? - Why don't Grails automatic timestamp fields work consistently in Oracle? Grails - grails.config.locations不适用于classpath和.properties文件 - Grails - grails.config.locations don't work with classpath and .properties file Grails 3.x-Grails 2.5.x的测试不起作用 - Grails 3.x - tests from grails 2.5.x don't work Grails ant任务不起作用 - 无法启动Grails:java.lang.reflect.InvocationTargetException - Grails ant tasks don't work - Unable to start Grails: java.lang.reflect.InvocationTargetException 为什么Domain类的静态方法不能在grails的“服务”内部工作? - Why don't Domain class static methods work from inside a grails “service”? Grails1.4M1 + GAE + gorm-jpa不起作用 - Grails1.4M1 + GAE + gorm-jpa don't work grails分页标记禁止访问方法 - grails pagination tag don't access method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM