catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
https://catamphetamine.gitlab.io/libphonenumber-js/
MIT License
2.8k stars 216 forks source link

isValidPhoneNumber and parsePhoneNumber validate the number incorrectly #444

Open SergeiEensalu opened 1 year ago

SergeiEensalu commented 1 year ago

If you call isValidPhoneNumber("+485555555"), it returns that it is a valid Polish number.

If you call parsePhoneNumber("+485555555"), then the result:

  PhoneNumber {
    country: 'PL',
    countryCallingCode: '48',
    nationalNumber: '5555555',
    number: '+485555555',
    metadata: {
    version: 4,
    ....
  }
}

Actually this is not true because 5555555 is not a Polish phone number. Exactly the same problem with the combination +481111111

Version "libphonenumber-js": "^1.10.30",

catamphetamine commented 1 year ago

What's the exact issue?

SergeiEensalu commented 1 year ago

isValidPhoneNumber("+485555555") returns true, but should return false.

catamphetamine commented 1 year ago

isValidPhoneNumber("+485555555") returns true, but should return false.

Provide an online demo illustrating the issue.

catamphetamine commented 1 year ago

And that online demo should use the "max" metadata

T-Lukashevich commented 1 year ago

Same problem with number +375854545 or +3758*****

https://github.com/catamphetamine/libphonenumber-js/assets/116653645/4cef5f16-54f2-4b94-8da6-66918324bee5

LMarcinkowski commented 7 months ago

Polish numbers has 9 digits, not 7.