validate Email - non-English Pattern
This commit is contained in:
@@ -2024,6 +2024,7 @@ func (s *InboundService) GetOnlineClients() []string {
|
||||
}
|
||||
|
||||
func validateEmail(email string) (bool, error) {
|
||||
|
||||
if strings.Contains(email, " ") {
|
||||
return false, errors.New("email contains spaces, please remove them")
|
||||
}
|
||||
@@ -2032,6 +2033,11 @@ func validateEmail(email string) (bool, error) {
|
||||
return false, errors.New("email contains uppercase letters, please convert to lowercase")
|
||||
}
|
||||
|
||||
nonEnglishPattern := `[^\x00-\x7F]`
|
||||
if regexp.MustCompile(nonEnglishPattern).MatchString(email) {
|
||||
return false, errors.New("email contains non-English characters, please use only English")
|
||||
}
|
||||
|
||||
emailPattern := `^[a-z0-9@._-]+$`
|
||||
if !regexp.MustCompile(emailPattern).MatchString(email) {
|
||||
return false, errors.New("email contains invalid characters, please use only lowercase letters, digits, and @._-")
|
||||
|
||||
Reference in New Issue
Block a user