对于domain实体简化验证的问题

1 view
Skip to first unread message

Alex wang

unread,
Jan 14, 2010, 11:42:21 PM1/14/10
to grailsunion
碰到一个现象,就是一个domain里有可能大多数的字段都是可以null的,只有个别的需要做非空验证,那么在constraints里挨着写就觉得麻烦,尤其是在字段比较多的时候,有没有全局设置的方式,比如在类上面做一个声明,默认是允许为空,需要个别设置的直接覆盖即可。

大家有什么好建议?

---------------------------------------------
Alex wang
website:颠覆软件 http://www.foxlog.org
twitter: http://twitter.com/foxlog
douban: http://www.douban.com/people/foxlog
gmail: idea.wang[at]gmail.com

Liu Chao

unread,
Jan 15, 2010, 12:00:35 AM1/15/10
to grail...@googlegroups.com
1.2里面把这个问题解决了。
在config里加上:
grails.gorm.default.constraints = {
   '*'(nullable:true, blank:false)
}

2010/1/15 Alex wang <idea...@gmail.com>
--
您收到此邮件是因为您订阅了 Google 网上论坛的“Grails联盟-GrailsUnion”论坛。
要向此网上论坛发帖,请发送电子邮件至 grail...@googlegroups.com
要取消订阅此网上论坛,请发送电子邮件至 grailsunion...@googlegroups.com
若有更多问题,请通过 http://groups.google.com/group/grailsunion?hl=zh-CN 访问此网上论坛。




--
My Grails Powered Website:
http://team.goal98.com

Grails Melody Plugin:
http://www.grails.org/plugin/grails-melody

Grails Templar Poject:
http://code.google.com/p/grails-templar/

Alex wang

unread,
Jan 15, 2010, 12:23:42 AM1/15/10
to grail...@googlegroups.com
不错,能在1.1.1的基础上打patch吗?

---------------------------------------------
Alex wang
website:颠覆软件 http://www.foxlog.org
twitter: http://twitter.com/foxlog
douban: http://www.douban.com/people/foxlog
gmail: idea.wang[at]gmail.com


2010/1/15 Liu Chao <liuc...@gmail.com>
Reply all
Reply to author
Forward
0 new messages