示例#1
0
 def validate_email(self, field):
     if re.fullmatch('^[a-zA-Z0-9\-._]+@[a-zA-Z0-9._\-]+\.[a-zA-Z0-9_\-]+$',
                     field.data) is None:
         raise ValidationError('Not a valid email address')
     if User.email_exists(
             field.data) and field.data != User.get_email(session['id']):
         raise ValidationError('email occupied')
示例#2
0
 def validate_email(self, field):
     if not User.email_exists(field.data):
         raise ValidationError('No such email in the database')