O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Validating email address syntax

In addition to the basic requirement that all fields must be filled out, the email address field must be a properly formatted email address. If the user fails to provide a properly formatted email address, a field-specific error message will inform the user that the email address syntax is incorrect.

We'll be using the EmailSyntax function from the validate package found within the shared folder:

const EmailRegex = `(?i)^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})+$`func EmailSyntax(email string) bool {  validationResult := false  r, err := regexp.Compile(EmailRegex)  if err != nil {    log.Fatal(err)  }  validationResult = r.MatchString(email)  return validationResult}

Recall that because the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required