formulator and validation
Clemens Klein-Robbenhaar <crobbenhaar-S0/[email protected]> Wed, 16 Mar 2005 23:42:29 +0100
| Newsgroups | gmane.comp.web.zope.formulator.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Seb, > > So it could be great to have a list of different format for IntegerFields, > FloatField... > > How this can be done ? May be like this : > The user enter a new value: 3 456,6 or 3,4566E+003 or 3456,6 > Then an "User Validator" would be in charge of changing it in something > that the python language can understand: 3456.6 > Then the "Actual Validator" will check it (start, end...) as it already > does. > And finally, once it is stored, a "Display Validator" would be in charge > of formatting the value for the display, so it will return: 3,4566 E+003 > > What do you think ? Hm, I think the question about what a "valid" input is depends quite a lot on the expected audience ... I just wonder how to get the different assumptions integrated into Formulator. Additionally I am not sure why one needs the distinction between "User Validator", "Actual Validator" and "Display Validator". I think it should be possible to e.g. extend the FloatValidator (which takes the part of the "Actual Validator"), override the "validate" method by first trimming the input to something the base class exists before calling the base class, so the code in the derived class is the "User Validator". Finally I think the "Display Validator" seems to end up in the widget, e.g. overriding the "render" method by passing in a possibly preformatted value in a derived class of the TextWidget. Maybe it is possible to define a "LenitentFormulatorFields" add-on product, which registers fields with more lenitent Validators, where the rgistration of \ more fields happens along of the lines of the RegexField, see http://www.zopelabs.com/cookbook/1059581374 Well, but maybe I am just that used to Formulators validate/widget mantra I just did not get the point of Your arguments. Cheers, Clemens