mirror of
https://github.com/gogf/gf.git
synced 2025-04-05 11:18:50 +08:00
util/gvalid: add 171
number support for virtual phone number validation (#3622)
This commit is contained in:
parent
e3a00d7f56
commit
59a775aad4
@ -394,8 +394,8 @@ func ExampleRule_Phone() {
|
||||
ctx = context.Background()
|
||||
req = BizReq{
|
||||
PhoneNumber1: "13578912345",
|
||||
PhoneNumber2: "11578912345", // error 11x not exist
|
||||
PhoneNumber3: "17178912345", // error 171 not exit
|
||||
PhoneNumber2: "17178912345",
|
||||
PhoneNumber3: "11578912345", // error 11x not exist
|
||||
PhoneNumber4: "1357891234", // error len must be 11
|
||||
}
|
||||
)
|
||||
@ -404,8 +404,7 @@ func ExampleRule_Phone() {
|
||||
}
|
||||
|
||||
// Output:
|
||||
// The PhoneNumber2 value `11578912345` is not a valid phone number
|
||||
// The PhoneNumber3 value `17178912345` is not a valid phone number
|
||||
// The PhoneNumber3 value `11578912345` is not a valid phone number
|
||||
// The PhoneNumber4 value `1357891234` is not a valid phone number
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,11 @@ import (
|
||||
// 3. China Telecom:
|
||||
// 133, 153, 180, 181, 189, 177(4G)
|
||||
//
|
||||
// 4. Satelite:
|
||||
// 4. Satellite:
|
||||
// 1349
|
||||
//
|
||||
// 5. Virtual:
|
||||
// 170, 173
|
||||
// 170, 171, 173
|
||||
//
|
||||
// 6. 2018:
|
||||
// 16x, 19x
|
||||
@ -51,7 +51,7 @@ func (r RulePhone) Message() string {
|
||||
|
||||
func (r RulePhone) Run(in RunInput) error {
|
||||
ok := gregex.IsMatchString(
|
||||
`^13[\d]{9}$|^14[5,7]{1}\d{8}$|^15[^4]{1}\d{8}$|^16[\d]{9}$|^17[0,2,3,5,6,7,8]{1}\d{8}$|^18[\d]{9}$|^19[\d]{9}$`,
|
||||
`^13[\d]{9}$|^14[5,7]{1}\d{8}$|^15[^4]{1}\d{8}$|^16[\d]{9}$|^17[0,1,2,3,5,6,7,8]{1}\d{8}$|^18[\d]{9}$|^19[\d]{9}$`,
|
||||
in.Value.String(),
|
||||
)
|
||||
if ok {
|
||||
|
Loading…
x
Reference in New Issue
Block a user