def validate_uri(uri, schemes = None, lang = 'en'): assert(type(uri) in types.StringTypes) if not uri_rex.match(uri): return bm_config.get_msg('invalid_uri') urit = urlparse.urlparse(uri) if schemes: colonx = uri.find(':') if colonx == -1: return bm_config.get_msg('uri_no_schema') if urit[0] not in schemes: return bm_config.get_msg('invalid_uri_schema') # # 2007-08-28 dpj # *new* make sure we have a proper domain name # if urit[0] in [ "http", "https", "ftp" ]: if not host_rex.match(urit[1]): return bm_config.get_msg("invalid_uri_host") return None
def validate_emails(email, lang = 'en'): """ Validate a list of emails, either separated by spaces or a comma """ assert(type(email) in types.StringTypes) if emails_rex.match(email) == None: return bm_config.get_msg("email_invalid", "Invalid e-mail address", lang = lang)
def validate_email(email, lang = 'en'): assert(type(email) in types.StringTypes) if email_rex.match(email) == None: return bm_config.get_msg("email_invalid", "Invalid e-mail address", lang = lang)