Chained validators and error messages
Andrea Riciputi <[email protected]> Wed, 4 Mar 2009 10:57:40 +0100
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I'm pretty new to Formencode, so please forgive my inexperience.
I'm trying to make htmlfill to put the error message raised by a
chained validator near a specific form field.
To get this I've written a custom validator where the messages dict is
defined like this:
messages = {'my_error_label': u"Error message goes here" }
then, if the conditions are not met I raise the Invalid exception like
this:
raise Invalid(self.message('my_error_label', state),
values, state,
error_dict={
'my_error_label': Invalid(self.message('field_name', state), values,
state)
})
Despite the fact this gives me the expected result, I'm not sure I'm
raising that exception in the correct way. I mean, I got the
impression that the Invalid instance could be called in easier way,
but I really can't see how. Any suggestion?
TIA,
Andrea
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H