migrate orion repo into monorepo structure
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/mail"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func NormalizeEmail(email string) (string, error) {
|
||||
if email == "" {
|
||||
return "", errors.New("email empty")
|
||||
}
|
||||
|
||||
lower := strings.ToLower(email)
|
||||
lower = strings.TrimSpace(lower)
|
||||
|
||||
parsed, err := mail.ParseAddress(lower)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return parsed.Address, nil
|
||||
}
|
||||
|
||||
func IsValidEmail(email string) bool {
|
||||
_, err := mail.ParseAddress(email)
|
||||
return err == nil
|
||||
}
|
||||
Reference in New Issue
Block a user