IS_LIST_OF does not apply to a single field but applies to the case
when you have multiple input fields with the same name. In this case
request.vars.fieldname contains a list of values (literally a python
list of strings, not a list in a string).
IS_LIST_OF(IS_INT_IN_RANGE(...)) would validate all elements of the
list as integer, for example. It is there but I never needed to use
it.
Massimo
On Oct 12, 11:51 am, billf <[EMAIL PROTECTED]> wrote:
> Massimo
>
> Many thanks for your MY_VALIDATOR. It works fine and helps me
> visualize writing my own validators. I still don't know what
> IS_LIST_OF does though :-)
>
> 5 part days into learning web2py and python from scratch I think I
> will leave t2 for a little while.
>
> Thanks again,
> Bill
>
> On Oct 12, 5:27 pm, mdipierro <[EMAIL PROTECTED]> wrote:
>
> > or you may want to consider
>
> > from applications.plugin_t2.modules.t2 import T2
>
> > db.yourtable.yourtable.widget=T2.tag_widget(['red','green','blue'])
>
> > Masimo
>
> > On Oct 12, 10:50 am, mdipierro <[EMAIL PROTECTED]> wrote:
>
> > > class MY_VALIDATOR:
> > > def __init__(self,theset=['red','green'],error_message='ouch!'):
> > > self.theset=theset
> > > self.em=error_message
> > > def _call_(self,value):
> > > items=[x.strip() for x in value.split(',')]
> > > for item in items:
> > > if not item in self.theset: return (value,self.em)
> > > return (','.join(items),None)
>
> > > On Oct 12, 9:19 am, billf <[EMAIL PROTECTED]> wrote:
>
> > > > Can anyone help with the following?
>
> > > > I want to validate an input string like "red,green,blue" where all the
> > > > elements occur in a list,e.g.
> > > > ['red','orange','yellow','green','blue','indigo','violet']
>
> > > > such that "red,green,blue" is valid and "puce,yellow" is invalid.
>
> > > > I was thinking that maybe IS_LIST_OF might be appropriate but I cannot
> > > > work out how to use it. Would it be useful with the above
> > > > requirement?
>
> > > > Bill
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---