focalboard/server/services/auth/email.go

14 lines
414 B
Go
Raw Normal View History

2021-03-18 08:32:23 +01:00
package auth
import "regexp"
2021-03-21 09:28:26 +01:00
var emailRegex = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
2021-03-18 08:32:23 +01:00
// IsEmailValid checks if the email provided passes the required structure and length.
func IsEmailValid(e string) bool {
2021-03-18 13:34:42 +01:00
if len(e) < 3 || len(e) > 254 {
2021-03-18 08:32:23 +01:00
return false
}
return emailRegex.MatchString(e)
}