17 lines
386 B
Go
17 lines
386 B
Go
package model
|
|
|
|
import (
|
|
merrors "git.sendico.io/tech/sxchnge/shared/errors"
|
|
"net/mail"
|
|
"strings"
|
|
)
|
|
|
|
func NormalizeEmail(email string) (string, error) {
|
|
email = strings.ToLower(strings.TrimSpace(email))
|
|
a, err := mail.ParseAddress(email)
|
|
if err != nil || a.Address != email || len(email) > 254 {
|
|
return "", merrors.InvalidArgument("valid email required")
|
|
}
|
|
return email, nil
|
|
}
|