Skip to content

Commit 2b4b459

Browse files
committed
chore: updated phone regex with tests
1 parent 609e4c2 commit 2b4b459

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/types/Patterns.test.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,25 @@ const TESTDATA = {
7171
],
7272
},
7373
PHONE: {
74-
valid: ['+1 123456789', '+44 1234567890', '+1 1234567890'],
75-
invalid: ['123456789', '+1 (12345) 7890', '+0 123456', '+12345678abc'],
74+
valid: [
75+
'+1 123456789',
76+
'+44 1234567890',
77+
'+11234567890',
78+
'+491746734234',
79+
'+49 1746734234',
80+
'+49 3012345678',
81+
'+81312345678',
82+
'+82212345678',
83+
'+447123456789',
84+
],
85+
invalid: [
86+
'123456789324324324332',
87+
'+1 (12345) 7890',
88+
'+0 123 456',
89+
'+12345678abc',
90+
'+81 31234-5678',
91+
'+447123456789 ',
92+
],
7693
},
7794
DOMAIN: {
7895
valid: [

src/types/Patterns.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const Patterns = {
4141
LABEL: /^[a-z0-9-_ ]{1,80}$/i,
4242
BPN: /^BPNL[0-9A-Z]{12}$/i,
4343
MAIL: /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*))@(([a-z0-9-]+\.)+[a-z]{2,})$/,
44-
PHONE: /^\+([1-9]\d{0,2})\s?\d{6,14}$/,
44+
PHONE: /^\+([1-9]\d{0,2})\s?\d{6,17}$/,
4545
DOMAIN: new RegExp(`^${DOMAIN.source}$`, 'i'),
4646
PATH: new RegExp(`^${URLPATH.source}$`, 'i'),
4747
URL: urlPattern,

0 commit comments

Comments
 (0)