formulator and validation

Sebastien Robin <[email protected]> Fri, 28 Jan 2005 16:04:23 +0100
Newsgroups gmane.comp.web.zope.formulator.devel
Message-ID <[email protected]>
Hi again,

I use so much the formulator and I really think it is so great.

But more I use it, more I think something is missing, something I will 
really need very soon, so may be I can write it, but I would like your 
ideas.

Actually, it is not  possible to specify a format for most of the fields. 
I would like the same kind of thing you did for the DateTimeField, 
applied to IntegerFields, StringFields, FloatField and probably all of 
them.

I will give you some examples.

Let's say you have to enter very big float, in a country where they use 
coma instead of dot, then you will want to enter this :

345 784 234 678,564

Of course, the final value should be 345784234678.564  , but probably it 
should be nice to have one way with the formulator to let more freedom to 
people, I don't think this is incorrect to enter a float with some spaces 
like this.

And also, you might want to display this number in an easy way to 
understand. In some countries we want to see :
345 784 234 678,564
And in some others :
345,784,234,678.564
And may be you only want 2 digits after the dot like this :
345,784,234,678.56
And may be you want it like this:
3,45784234678564 E+011

May be you can think about SpreadSheets where this kind of thing is 
possible. I should also be very great to have it for formulator.

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 ?

  Seb.
-- 
Sebastien Robin, Nexedi Technical Director
Nexedi: Consulting and Development of Free / Open Source Software
http://www.nexedi.com
ERP5: Free / Open Source ERP Software for small and medium companies
http://www.erp5.org
Storever: OpenBrick, WiFi infrastructure, notebooks and servers
http://www.storever.com