Re: Problems with Formencode Msgs, Unexpected Inputs
"Tom Longson (nym)" <[email protected]> Fri, 3 Oct 2008 15:05:26 -0700
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
Thank you for your quick feedback. On the schema, allow_extra_fields actually got it to stop complaining about fields that I didn't care about. A followup question (hopefully my last), how do you explicitly order the execution of validatiors in a schema. For example, i want the password validator to fire off before the password_confirm FieldsMatch validator. Thank you, nym On Fri, Oct 3, 2008 at 11:41 AM, Ian Bicking <[email protected]> wrote: > Tom Longson (nym) wrote: > >> Hi, >> >> I'm trying to get formencode to work, and I have a few problems: >> >> 1. How do you supply custom error messages? I've read the documentation, >> and couldn't find a concrete example using preexisting validators. >> > > Each validator has a list of messages, which you can see in the docs. For > instance, Regex(r'^\w+$', messages={'invalid': 'Please enter just letters > and numbers'}). > > 2. Why am i getting this error list with the included test file? >> >> List of dictionaries: >> [{'name': 'Tom'}, {'email': >> 'tom-1ejvVKqOCHmevrI51Aqiyd1ocvOgFGy0LpsAlfeDtJ10ubjbjo6WXg@public.gmane.org >> <mailto:tom-1ejvVKqOCHmevrI51Aqiyd1ocvOgFGy0LpsAlfeDtJ10ubjbjo6WXg@public.gmane.org>'}, {'password': >> 'narfffff0'}, {'password_confirm': 'narfffff0'}] >> >> Error list: >> [Invalid('email: Missing value\npassword: Missing >> value\npassword_confirm: Missing value',), Invalid('name: Missing >> value\npassword: Missing value\npassword_confirm: Missing value',), >> Invalid('email: Missing value\nname: Missing >> value\npassword_confirm: Missing value',), Invalid('email: Missing >> value\nname: Missing value\npassword: Missing value',)] >> > > You get a single exception for invalid input, that contains all the > exceptions for the individual fields. Probably you'll find it easiest to > use exc.unpack_errors() to get a list of messages. > > 3. If I supply a value to the list of dictionaries that is not expected by >> the Schema (e.g. "foobar"), how do I get the Schema to ignore it instead of >> throwing an Invalid(u"The input field '%s' was not expected.",) ? >> > > on the schema, filter_extra_fields=True. > > -- > Ian Bicking : [email protected] : http://blog.ianbicking.org > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ FormEncode-discuss mailing list FormEncode-discuss-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/formencode-discuss