Skip to content

Commit 01eeaef

Browse files
AnnaMariaJansenAnna-Maria Jansen
and
Anna-Maria Jansen
authored
feat(isMobilePhone): change the german prefix from '+490' to '+49' or '0' (validatorjs#1679)
* fix: restrict german numbers * fix: allow 0 prefix Co-authored-by: Anna-Maria Jansen <[email protected]>
1 parent 044159d commit 01eeaef

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/lib/isMobilePhone.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const phones = {
2525
'ca-AD': /^(\+376)?[346]\d{5}$/,
2626
'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
2727
'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
28-
'de-DE': /^(\+49)?0?[1|3]([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7}$/,
28+
'de-DE': /^((\+49|0)[1|3])([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7,9}$/,
2929
'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
3030
'de-CH': /^(\+41|0)([1-9])\d{1,9}$/,
3131
'de-LU': /^(\+352)?((6\d1)\d{6})$/,

test/validators.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -5828,21 +5828,20 @@ describe('Validators', () => {
58285828
{
58295829
locale: 'de-DE',
58305830
valid: [
5831-
'+49015123456789',
58325831
'+4915123456789',
58335832
'+4930405044550',
58345833
'015123456789',
5835-
'15123456789',
5836-
'15623456789',
5837-
'15623456789',
5838-
'1601234567',
5839-
'16012345678',
5840-
'1621234567',
5841-
'1631234567',
5842-
'1701234567',
5843-
'17612345678',
5844-
'15345678910',
5845-
'15412345678',
5834+
'015123456789',
5835+
'015623456789',
5836+
'015623456789',
5837+
'01601234567',
5838+
'016012345678',
5839+
'01621234567',
5840+
'01631234567',
5841+
'01701234567',
5842+
'017612345678',
5843+
'015345678910',
5844+
'015412345678',
58465845
],
58475846
invalid: [
58485847
'34412345678',
@@ -5852,6 +5851,7 @@ describe('Validators', () => {
58525851
'16412345678',
58535852
'17012345678',
58545853
'+4912345678910',
5854+
'+49015123456789',
58555855
],
58565856
},
58575857
{

0 commit comments

Comments
 (0)