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
-~----------~----~----~----~------~----~------~--~---

Reply via email to