25 lines
471 B
Go
25 lines
471 B
Go
package entity
|
|
|
|
import (
|
|
"regexp"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
var testEmailRe = regexp.MustCompile(`^test(0[1-9]|[1-9][0-9]|100)@spark\.com$`)
|
|
|
|
// EmailBinding maps one normalized email to one user.
|
|
type EmailBinding struct {
|
|
Email string
|
|
UserID int64
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
func NormalizeEmail(email string) string {
|
|
return strings.ToLower(strings.TrimSpace(email))
|
|
}
|
|
|
|
func IsTestEmail(email string) bool {
|
|
return testEmailRe.MatchString(NormalizeEmail(email))
|
|
}
|