mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-27 19:35:49 +08:00
fix email regex rule
This commit is contained in:
@@ -26,6 +26,7 @@ require (
|
||||
github.com/qiniu/go-sdk/v7 v7.14.0
|
||||
github.com/shirou/gopsutil/v3 v3.23.3
|
||||
github.com/silenceper/wechat/v2 v2.1.4
|
||||
github.com/stretchr/testify v1.8.3
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.633
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.633
|
||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.41
|
||||
@@ -95,6 +96,7 @@ require (
|
||||
github.com/mozillazg/go-httpheader v0.2.1 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.14 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/richardlehane/mscfb v1.0.4 // indirect
|
||||
|
@@ -457,6 +457,7 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
|
||||
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.194/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.633 h1:Yj8s35IjbgaHp4Ic9BZLVGWdN2gXBMtwYi1JJ+qYbrc=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.633/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
|
||||
|
@@ -89,8 +89,8 @@ func IsMobile(mobile string) bool {
|
||||
|
||||
// IsEmail 是否为邮箱地址
|
||||
func IsEmail(email string) bool {
|
||||
// pattern := `\w+([-+.]\w+)@\w+([-.]\w+).\w+([-.]\w+)*` //匹配电子邮箱
|
||||
pattern := `^[0-9a-z][_.0-9a-z-]{0,31}@([0-9a-z][0-9a-z-]{0,30}[0-9a-z].){1,4}[a-z]{2,4}$`
|
||||
// pattern := `^[0-9a-z][_.0-9a-z-]{0,31}@([0-9a-z][0-9a-z-]{0,30}[0-9a-z].){1,4}[a-z]{2,4}$` //匹配电子邮箱
|
||||
pattern := `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`
|
||||
reg := regexp.MustCompile(pattern)
|
||||
return reg.MatchString(email)
|
||||
}
|
||||
|
11
server/utility/validate/validate_test.go
Normal file
11
server/utility/validate/validate_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package validate
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIsEmail(t *testing.T) {
|
||||
b := IsEmail("QTT123456@163.com")
|
||||
assert.True(t, b, "ok~")
|
||||
}
|
Reference in New Issue
Block a user