Thank you Bruno for this! Exactly what I was looking for. 

Maybe it would be a good idea to add it as a "multiple" parameter to 
standard IS_EMAIL(multiple=True, ...)

In any case, thanks :)

On Wednesday, July 6, 2011 4:39:39 AM UTC-4, rochacbruno wrote:
>
> forget the latest, I wrote directly here in email and there were errors. 
>
> This is the tested code:
>
> ### put in models ###
>
> class IS_EMAIL_LIST(object):
>     def __init__(self, error_message="Email %s is invalid", sep=","):
>         self.error_message = error_message
>         self.sep = sep
>         
>     def __call__(self, value):
>             emails = 
> value.strip().replace('\n','').replace('\t','').split(self.sep)
>             for email in emails:
>                 email = email.strip()
>                 if IS_EMAIL()(email)[1] != None:
>                     return (email, self.error_message % email)
>             return (emails, None)     
>
> db.define_table('emails',
>                 Field('list','text', requires=IS_EMAIL_LIST())
>                 )
>
> ###################
>

-- 



Reply via email to