Skip to content

Commit

Permalink
util/gvalid: add 171 number support for virtual phone number valida…
Browse files Browse the repository at this point in the history
…tion (#3622)
  • Loading branch information
swift-fs authored Jun 4, 2024
1 parent e3a00d7 commit 59a775a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions util/gvalid/gvalid_z_example_feature_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)
Expand All @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions util/gvalid/internal/builtin/builtin_phone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 59a775a

Please sign in to comment.