On Thu, Jul 21, 2011 at 12:00 PM, Branko Vukelic <[email protected]> wrote:
> myForm = form.Form(
> ....
> validators = [
> form.Validator('You need at least one field,
> lambda i: any([not_empty(i.field1), not_empty(i.field2)...]),
> ]
> )
One more note. The reason I say ``not_empty(i.field)`` instead of just
saying ``i.field`` is that in Python, a string that contains multiple
spaces is also True. So you cannot rely on that. A not_empty would do
something like this:
def not_empty(s):
return s.strip() and True or False
It's a slightly more robust check.
--
Branko Vukelić
[email protected]
Lead Developer
Herd Hound (tm) - Travel that doesn't bite
www.herdhound.com
Love coffee? You might love Loveffee, too.
loveffee.appspot.com
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.