- handle ebai fake mobile(IsMobileFake)

This commit is contained in:
gazebo
2018-11-14 15:05:40 +08:00
parent 598659582d
commit a84286df4f
3 changed files with 25 additions and 0 deletions

View File

@@ -187,3 +187,8 @@ func Int2OneZero(value int) int {
}
return 0
}
// 判断电话号码是否是假的,比如有****号
func IsMobileFake(mobile string) bool {
return utils.Str2Int64WithDefault(strings.Replace(strings.Replace(mobile, "-", "", -1), ",", "", -1), 0) == 0
}

View File

@@ -46,3 +46,18 @@ func TestFakeID(t *testing.T) {
t.Fatalf("wrong result for id:%d", id)
}
}
func TestIsMobileFake(t *testing.T) {
if IsMobileFake("13888888888") {
t.Fatal("wrong 1")
}
if IsMobileFake("13888888888-123") {
t.Fatal("wrong 2")
}
if IsMobileFake("13888888888,123") {
t.Fatal("wrong 3")
}
if !IsMobileFake("138****8888") {
t.Fatal("wrong 4")
}
}