Skip to content

Commit 23e854f

Browse files
yisibltheteladras
authored andcommitted
fix(isMobilePhone): use a loose and future-oriented way to verify Chinese mobile phone numbers (validatorjs#1682)
1 parent 6e74c14 commit 23e854f

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
@@ -115,7 +115,7 @@ const phones = {
115115
'uk-UA': /^(\+?38|8)?0\d{9}$/,
116116
'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
117117
'vi-VN': /^((\+?84)|0)((3([2-9]))|(5([25689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/,
118-
'zh-CN': /^((\+|00)86)?1([3456789][0-9]|4[579]|6[2567]|7[01235678]|9[012356789])[0-9]{8}$/,
118+
'zh-CN': /^((\+|00)86)?(1[3-9]|9[28])\d{9}$/,
119119
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
120120
};
121121
/* eslint-enable max-len */

test/validators.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6183,19 +6183,28 @@ describe('Validators', () => {
61836183
{
61846184
locale: 'zh-CN',
61856185
valid: [
6186-
'15323456787',
61876186
'13523333233',
6188-
'13898728332',
6187+
'13838389438',
6188+
'14899230918',
6189+
'14999230918',
6190+
'15323456787',
6191+
'15052052020',
6192+
'16237108167',
6193+
'008616238234822',
6194+
'+8616238234822',
6195+
'16565600001',
6196+
'17269427292',
6197+
'17469427292',
6198+
'18199617480',
6199+
'19151751717',
6200+
'19651751717',
61896201
'+8613238234822',
61906202
'+8613487234567',
61916203
'+8617823492338',
61926204
'+8617823492338',
6193-
'16637108167',
61946205
'+8616637108167',
61956206
'+8616637108167',
61966207
'+8616712341234',
6197-
'008618812341234',
6198-
'008618812341234',
61996208
'+8619912341234',
62006209
'+8619812341234',
62016210
'+8619712341234',
@@ -6204,17 +6213,25 @@ describe('Validators', () => {
62046213
'+8619312341234',
62056214
'+8619212341234',
62066215
'+8619112341234',
6207-
'17269427292',
6208-
'16565600001',
62096216
'+8617269427292',
6217+
'008618812341234',
6218+
'008618812341234',
62106219
'008617269427292',
6211-
'16238234822',
6212-
'008616238234822',
6213-
'+8616238234822',
6220+
// Reserve number segments in the future.
6221+
'92138389438',
6222+
'+8692138389438',
6223+
'008692138389438',
6224+
'98199649964',
6225+
'+8698099649964',
6226+
'008698099649964',
62146227
],
62156228
invalid: [
62166229
'12345',
62176230
'',
6231+
'12038389438',
6232+
'12838389438',
6233+
'013838389438',
6234+
'+86-13838389438',
62186235
'+08613811211114',
62196236
'+008613811211114',
62206237
'08613811211114',

0 commit comments

Comments
 (0)