-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
fix: use a loose and future-oriented way to verify Chinese mobile phone numbers #1682
Conversation
src/lib/isMobilePhone.js
Outdated
@@ -114,7 +114,7 @@ const phones = { | |||
'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}$/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already 1([3456789][0-9]
, the following |4[579]|6[67]|7[01235678]|9[012356789]
is meaningless.
@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.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adopt
Thanks for your PR, please fix the merge conflicts. |
@profnandaa Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks.
Can we merge now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yisibl Sorry for the long delay! Your PR will be merged asap
@tux-tn Thanks! |
…nese mobile phone numbers (validatorjs#1682)
…nese mobile phone numbers (#1682)
…nese mobile phone numbers (#1682)
The current
zh-CN
mobile 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