Skip to content

Commit efc738e

Browse files
committed
fix: use a loose and future-oriented way to verify Chinese mobile phone numbers.
1 parent e08e79a commit efc738e

2 files changed

Lines changed: 28 additions & 11 deletions

File tree

src/lib/isMobilePhone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const phones = {
114114
'uk-UA': /^(\+?38|8)?0\d{9}$/,
115115
'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
116116
'vi-VN': /^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/,
117-
'zh-CN': /^((\+|00)86)?1([3456789][0-9]|4[579]|6[2567]|7[01235678]|9[012356789])[0-9]{8}$/,
117+
'zh-CN': /^((\+|00)86)?(1[3-9]|9[28])\d{9}$/,
118118
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
119119
};
120120
/* eslint-enable max-len */

test/validators.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5962,19 +5962,28 @@ describe('Validators', () => {
59625962
{
59635963
locale: 'zh-CN',
59645964
valid: [
5965-
'15323456787',
59665965
'13523333233',
5967-
'13898728332',
5966+
'13838389438',
5967+
'14899230918',
5968+
'14999230918',
5969+
'15323456787',
5970+
'15052052020',
5971+
'16237108167',
5972+
'008616238234822',
5973+
'+8616238234822',
5974+
'16565600001',
5975+
'17269427292',
5976+
'17469427292',
5977+
'18199617480',
5978+
'19151751717',
5979+
'19651751717',
59685980
'+8613238234822',
59695981
'+8613487234567',
59705982
'+8617823492338',
59715983
'+8617823492338',
5972-
'16637108167',
59735984
'+8616637108167',
59745985
'+8616637108167',
59755986
'+8616712341234',
5976-
'008618812341234',
5977-
'008618812341234',
59785987
'+8619912341234',
59795988
'+8619812341234',
59805989
'+8619712341234',
@@ -5983,17 +5992,25 @@ describe('Validators', () => {
59835992
'+8619312341234',
59845993
'+8619212341234',
59855994
'+8619112341234',
5986-
'17269427292',
5987-
'16565600001',
59885995
'+8617269427292',
5996+
'008618812341234',
5997+
'008618812341234',
59895998
'008617269427292',
5990-
'16238234822',
5991-
'008616238234822',
5992-
'+8616238234822',
5999+
// Reserve number segments in the future.
6000+
'92138389438',
6001+
'+8692138389438',
6002+
'008692138389438',
6003+
'98199649964',
6004+
'+8698099649964',
6005+
'008698099649964',
59936006
],
59946007
invalid: [
59956008
'12345',
59966009
'',
6010+
'12038389438',
6011+
'12838389438',
6012+
'013838389438',
6013+
'+86-13838389438',
59976014
'+08613811211114',
59986015
'+008613811211114',
59996016
'08613811211114',

0 commit comments

Comments
 (0)