Skip to content

Commit ed667ed

Browse files
committed
chore: updated phone regex with tests
1 parent 5e81252 commit ed667ed

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
@@ -90,8 +90,25 @@ const TESTDATA = {
9090
],
9191
},
9292
PHONE: {
93-
valid: ['+1 123456789', '+44 1234567890', '+1 1234567890'],
94-
invalid: ['123456789', '+1 (12345) 7890', '+0 123456', '+12345678abc'],
93+
valid: [
94+
'+1 123456789',
95+
'+44 1234567890',
96+
'+11234567890',
97+
'+491746734234',
98+
'+49 1746734234',
99+
'+49 3012345678',
100+
'+81312345678',
101+
'+82212345678',
102+
'+447123456789',
103+
],
104+
invalid: [
105+
'123456789324324324332',
106+
'+1 (12345) 7890',
107+
'+0 123 456',
108+
'+12345678abc',
109+
'+81 31234-5678',
110+
'+447123456789 ',
111+
],
95112
},
96113
DOMAIN: {
97114
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)