Re: Question about chained validators
Ian Bicking <[email protected]> Mon, 20 Apr 2009 10:51:32 -0500
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
Huh, looking at the code I think there's a bug. I'll look into it. On Sun, Apr 19, 2009 at 4:26 PM, Andrea Riciputi <[email protected]>wrote: > Hi all, > I've noticed that a chained validator with validate_partial_form=True > is called twice. The first time its .validate_partial() method is > called (which in turn calls .validate_python()), > then .validate_python() is called directly. > > The problem is that the second time the input has been already > converted and the validators could fails (e.g. if the input string has > been converted into a datetime object). > > Probably I haven't understood how to get this kind of validators to > work properly. I usually define them like this: > > class Foo(FancyValidator): > validate_partial_form = True > messages = { > 'message_key' : u"the message" > } > > def validate_partial(self, values, state): > self.validate_python(values, state) > > def validate_python(self, values, state): > ...actual validating code here... > ...raise Invalid in case... > > Can anyone explain me why I get this wrong? > > TIA, > Andrea > > > ------------------------------------------------------------------------------ > Stay on top of everything new and different, both inside and > around Java (TM) technology - register by April 22, and save > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > 300 plus technical and hands-on sessions. Register today. > Use priority code J9JMT32. http://p.sf.net/sfu/p > _______________________________________________ > FormEncode-discuss mailing list > FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > https://lists.sourceforge.net/lists/listinfo/formencode-discuss > -- Ian Bicking | http://blog.ianbicking.org ------------------------------------------------------------------------------ Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. 300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p _______________________________________________ FormEncode-discuss mailing list FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/formencode-discuss