Re: FormEncode form validators
Ian Bicking <[email protected]>
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
Felix Schwarz wrote:
> Ian Bicking wrote:
>> Do people have classes or recipes they've written that are general
>> enough to include directly in FormEncode? If so, please contribute!
>> Realistic examples in the docstrings will be very helpful.
>
> I have some validators which might be useful:
> * RestrictedInteger (min, max, may be marked as optional)
The optional part can just be given with if_missing, no? (Or
if_empty/if_invalid)
validators.Int already has min/max.
> * PartialDate - FormValidator which takes three fields as day/month/year
> and ensures that these fields form are valid date while some date
> parts may be missing (e.g. year is missing so only day+month can be
> validated).
That could be useful, as long the options don't get overwhelming.
Though I've generally stayed away from compound date validators, because
they seem generally unnecessary to me if you have good string field parsing.
Also, for dates if you use variabledecode you can name your fields
things like date.year, date.month, date.day, and do:
class MySchema(Schema):
date = DateValidator()
And the validator should get a dictionary with year/month/day keys.
> * a custom unicode string validator which works as I expected the
> FormEncode one
> initially.
How is it different from the current UnicodeString? Can the
functionality be merged in there directly?
--
Ian Bicking : [email protected] : http://blog.ianbicking.org
: Write code, do good : http://topp.openplans.org/careers
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/