mirror of
https://github.com/eduardolat/pgbackweb.git
synced 2026-01-25 14:08:36 -06:00
18 lines
438 B
Go
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)
|
|
}
|