1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 22:50:55 +00:00

Merge pull request #3464 from zhl11b/develop

手机号起始三位补全
This commit is contained in:
astaxie 2019-01-08 23:54:00 +08:00 committed by GitHub
commit 6892369cc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 13 deletions

View File

@ -268,6 +268,18 @@ func TestMobile(t *testing.T) {
if !valid.Mobile("+8614700008888", "mobile").Ok { if !valid.Mobile("+8614700008888", "mobile").Ok {
t.Error("\"+8614700008888\" is a valid mobile phone number should be true") t.Error("\"+8614700008888\" is a valid mobile phone number should be true")
} }
if !valid.Mobile("17300008888", "mobile").Ok {
t.Error("\"17300008888\" is a valid mobile phone number should be true")
}
if !valid.Mobile("+8617100008888", "mobile").Ok {
t.Error("\"+8617100008888\" is a valid mobile phone number should be true")
}
if !valid.Mobile("8617500008888", "mobile").Ok {
t.Error("\"8617500008888\" is a valid mobile phone number should be true")
}
if valid.Mobile("8617400008888", "mobile").Ok {
t.Error("\"8617400008888\" is a valid mobile phone number should be false")
}
} }
func TestTel(t *testing.T) { func TestTel(t *testing.T) {
@ -524,7 +536,6 @@ func TestPointer(t *testing.T) {
} }
} }
func TestCanSkipAlso(t *testing.T) { func TestCanSkipAlso(t *testing.T) {
type User struct { type User struct {
ID int ID int
@ -560,4 +571,3 @@ func TestCanSkipAlso(t *testing.T) {
} }
} }

View File

@ -632,7 +632,7 @@ func (b Base64) GetLimitValue() interface{} {
} }
// just for chinese mobile phone number // just for chinese mobile phone number
var mobilePattern = regexp.MustCompile(`^((\+86)|(86))?(1(([35][0-9])|[8][0-9]|[7][06789]|[4][579]))\d{8}$`) var mobilePattern = regexp.MustCompile(`^((\+86)|(86))?(1(([35][0-9])|[8][0-9]|[7][01356789]|[4][579]))\d{8}$`)
// Mobile check struct // Mobile check struct
type Mobile struct { type Mobile struct {