fix: use a loose and future-oriented way to verify Chinese mobile phone numbers#1682
Merged
profnandaa merged 1 commit intovalidatorjs:masterfrom Oct 30, 2021
Merged
Conversation
yisibl
commented
Jun 9, 2021
src/lib/isMobilePhone.js
Outdated
| 'uk-UA': /^(\+?38|8)?0\d{9}$/, | ||
| 'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/, | ||
| 'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/, | ||
| 'zh-CN': /^((\+|00)86)?1([3456789][0-9]|4[579]|6[67]|7[01235678]|9[012356789])[0-9]{8}$/, |
Contributor
Author
There was a problem hiding this comment.
There is already 1([3456789][0-9], the following |4[579]|6[67]|7[01235678]|9[012356789] is meaningless.
Contributor
Author
Contributor
|
@yisibl 我那个PR是3年前提交的,确实有点过时了。 |
Codecov Report
@@ Coverage Diff @@
## master #1682 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 101 101
Lines 1862 1862
=========================================
Hits 1862 1862
Continue to review full report at Codecov.
|
mlinquan
approved these changes
Jun 23, 2021
Member
|
Thanks for your PR, please fix the merge conflicts. |
Contributor
Author
|
@profnandaa Done. |
Member
Contributor
Author
Contributor
Author
|
Can we merge now? |
Contributor
Author
|
@tux-tn Thanks! |
theteladras
pushed a commit
to theteladras/validator.js
that referenced
this pull request
Oct 30, 2021
…nese mobile phone numbers (validatorjs#1682)
profnandaa
pushed a commit
that referenced
this pull request
Oct 31, 2021
…nese mobile phone numbers (#1682)
profnandaa
pushed a commit
that referenced
this pull request
Oct 31, 2021
…nese mobile phone numbers (#1682)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current
zh-CNmobile phone number verification rules are too strict. With the increasing number of mobile phone numbers in China, this regularity will become difficult to maintain.To this end, we should follow the official document (《电信网编号计划(2017年版)》) only need to verify the first two digits. This is a word document. For the convenience of viewing, I made a screenshot.
In this table, all mobile phone numbers from 13 to 19 exist except those starting with 12, and the addition of mobile phone numbers starting with 92 and 98 will be considered in the future. For better compatibility with the future, this PR also added 92/98 support. In addition, this PR does not consider IoT numbers.
ps: This library maintains a more detailed operator mobile phone number: https://github.com/VincentSit/ChinaMobilePhoneNumberRegex#rules
Checklist