Skip to content

Commit

Permalink
fix(isMobilePhone): use a loose and future-oriented way to verify Chi…
Browse files Browse the repository at this point in the history
…nese mobile phone numbers (#1682)
  • Loading branch information
yisibl authored and profnandaa committed Oct 31, 2021
1 parent 9ade03b commit d3f5e2d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/lib/isMobilePhone.js
Expand Up @@ -116,7 +116,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([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/,
'zh-CN': /^((\+|00)86)?1([3456789][0-9]|4[579]|6[2567]|7[01235678]|9[012356789])[0-9]{8}$/,
'zh-CN': /^((\+|00)86)?(1[3-9]|9[28])\d{9}$/,
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
};
/* eslint-enable max-len */
Expand Down
37 changes: 27 additions & 10 deletions test/validators.js
Expand Up @@ -6114,19 +6114,28 @@ describe('Validators', () => {
{
locale: 'zh-CN',
valid: [
'15323456787',
'13523333233',
'13898728332',
'13838389438',
'14899230918',
'14999230918',
'15323456787',
'15052052020',
'16237108167',
'008616238234822',
'+8616238234822',
'16565600001',
'17269427292',
'17469427292',
'18199617480',
'19151751717',
'19651751717',
'+8613238234822',
'+8613487234567',
'+8617823492338',
'+8617823492338',
'16637108167',
'+8616637108167',
'+8616637108167',
'+8616712341234',
'008618812341234',
'008618812341234',
'+8619912341234',
'+8619812341234',
'+8619712341234',
Expand All @@ -6135,17 +6144,25 @@ describe('Validators', () => {
'+8619312341234',
'+8619212341234',
'+8619112341234',
'17269427292',
'16565600001',
'+8617269427292',
'008618812341234',
'008618812341234',
'008617269427292',
'16238234822',
'008616238234822',
'+8616238234822',
// Reserve number segments in the future.
'92138389438',
'+8692138389438',
'008692138389438',
'98199649964',
'+8698099649964',
'008698099649964',
],
invalid: [
'12345',
'',
'12038389438',
'12838389438',
'013838389438',
'+86-13838389438',
'+08613811211114',
'+008613811211114',
'08613811211114',
Expand Down

0 comments on commit d3f5e2d

Please sign in to comment.