Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positives with German mobile phone numbers #1670

Closed
tobiaseisenschenk opened this issue May 6, 2021 · 2 comments · Fixed by #1679
Closed

False positives with German mobile phone numbers #1670

tobiaseisenschenk opened this issue May 6, 2021 · 2 comments · Fixed by #1679

Comments

@tobiaseisenschenk
Copy link

Describe the bug
Mobile phone numbers in Germany start with a 0 prefix such as 0157xxxxxxx. However the preceding 0 is dropped if the country code prefix +49 is added. This is described on this wikipedia page. Therefore the related change made a while ago is not restrictive enough.

Examples
invalid:
'+49015123456789'
valid:
'+4915123456789'

Additional context
Validator.js version: 13.6.0
Node.js version: v12.15.0
OS platform: macOS

@profnandaa
Copy link
Member

Thanks for raising. You are right, PR welcome!

@Burnett01
Copy link

Burnett01 commented May 24, 2021

Hey guys, I have submitted a PR #1675 for this issue, but the validation of german mobile phone numbers overall is still not correct.

I was wondering as to why a number such as 030556699884 is deemed a valid german mobile phone number.
The format of that number is only valid for landline phones and is subject to a state in Germany, Berlin.

According to Wikipedia and the federal agency of networking (Bundesnetzagentur), german mobile phone numbers always start with either +49|0 and 1, for example: 017699988855 (+4917699988855).

Numbers for mobile services commence with a two-digit service code. The service code is
followed by a subscriber number consisting of a block code and a terminal equipment
number. When dialling the number from a German landline or mobile number, the number
must be preceded by the prefix "0".
(Source)

The change introduced with #1378 (#1391) is invalid as it includes local (landline) phone numbers for Berlin as well, but those are not mobile phone numbers. (See #941)

Additonally, the change introduced with #933 is probably incorrect as well, as it would allow for german mobile phone numbers without a leading country code (+49) or zero (0). This only makes sense when the userland code explicitly offers two input fields where the first one already contains +49 or 0, and only the second one gets validated.

Example:

<input type="text" value="+49" readonly/> <input type="text" placeholder="Enter number" readonly/>

But then again, this is subject to userland and shouldn't be part of this library.

If it's of any help, I have created another branch called fix/improve-german-phone-validation in my fork where german mobile phone numbers are strictly validated (where the leading country code (+49) or 0 must be present and landlines are not included.).: Burnett01@a98ca0c

Greetings, Steve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants