Skip to content

Commit

Permalink
Merge pull request #140 from icey-yu/feat-email
Browse files Browse the repository at this point in the history
feat: check email
  • Loading branch information
icey-yu authored Oct 14, 2024
2 parents 35ae386 + 8ee3832 commit ef74300
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions utils/stringutil/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"github.com/pkg/errors"
"hash/crc32"
"regexp"
"runtime"
"strconv"
"strings"
Expand Down Expand Up @@ -299,3 +300,9 @@ func IsAlphanumeric(s string) bool {
}
return true
}

// IsValidEmail checks if the input string is a valid email address.
func IsValidEmail(email string) bool {
re := regexp.MustCompile(`^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`)
return re.MatchString(email)
}

0 comments on commit ef74300

Please sign in to comment.