Created
July 6, 2011 08:41
-
-
Save rochacbruno/1066850 to your computer and use it in GitHub Desktop.
IS EMAIL LIST validator for web2py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment