File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -7,10 +7,11 @@ import (
77)
88
99var (
10- isUUIDRegexp = regexp .MustCompile (` [0-9a-fA-F]{8}\ -[0-9a-fA-F]{4}\ -[0-9a-fA-F]{4}\ -[0-9a-fA-F]{4}\ -[0-9a-fA-F]{12}` )
10+ isUUIDRegexp = regexp .MustCompile ("^ [0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" )
1111 isRegionRegex = regexp .MustCompile ("^[a-z]{2}-[a-z]{3}$" )
1212 isZoneRegex = regexp .MustCompile ("^[a-z]{2}-[a-z]{3}-[1-9]$" )
1313 isAccessKey = regexp .MustCompile ("^SCW[A-Z0-9]{17}$" )
14+ isEmailRegexp = regexp .MustCompile ("^.+@.+$" )
1415)
1516
1617// IsUUID returns true if the given string has a valid UUID format.
@@ -48,3 +49,8 @@ func IsURL(s string) bool {
4849 _ , err := url .Parse (s )
4950 return err == nil
5051}
52+
53+ // IsEmail returns true if the given string has an email format.
54+ func IsEmail (v string ) bool {
55+ return isEmailRegexp .MatchString (v )
56+ }
You can’t perform that action at this time.
0 commit comments