Files
pgbackweb/internal/validate/email.go
Luis Eduardo Jeréz Girón f3a8efe69a Add email and struct validation
2024-07-22 20:33:23 -06:00

18 lines
438 B
Go

package validate
import "regexp"
// Email validates an email address.
// It returns a boolean indicating whether
// the email is valid or not.
func Email(email string) bool {
// Regular expression to match email format
regex := `^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$`
// Compile the regular expression
re := regexp.MustCompile(regex)
// Match the email against the regular expression
return re.MatchString(email)
}