You can download this code by clicking the button below.
This code is now available for download.
This function is used to validate whether the input string conforms to the format of an email address. If it does not conform, a ValidationError exception is raised.
Technology Stack : wtforms, re (regular expressions)
Code Type : Validation function
Code Difficulty : Intermediate
def validate_email(form, field):
if field.data and not re.match(r"[^@]+@[^@]+\.[^@]+", field.data):
raise ValidationError('Invalid email address.')