Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(util/gvalid): add 171 series number support for virtual phone number validation #3622

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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