libphonenumber-js icon indicating copy to clipboard operation
libphonenumber-js copied to clipboard

isValidPhoneNumber and parsePhoneNumber validate the number incorrectly

Open SergeiEensalu opened this issue 1 year ago • 6 comments

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

  • Google demo: https://libphonenumber.appspot.com/phonenumberparser?number=5555555&country=PL
  • libphonenumber-js demo: https://catamphetamine.gitlab.io/libphonenumber-js/?parseCountry=PL&parseValue=5555555&asYouTypeCountry=US&findNumbersCountry=US&findNumbersText=For%20more%20details%20call%20%2B7%20(800)%20555-35-35%20internationally%20or%20reach%20the%20local%20US%20branch%20at%20(213)%20373-4253%20ext.%201234%20for%20paid%20customer%20support.

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

SergeiEensalu avatar May 22 '23 10:05 SergeiEensalu

What's the exact issue?

catamphetamine avatar May 22 '23 10:05 catamphetamine

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

SergeiEensalu avatar May 22 '23 10:05 SergeiEensalu

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

Provide an online demo illustrating the issue.

catamphetamine avatar May 22 '23 10:05 catamphetamine

And that online demo should use the "max" metadata

catamphetamine avatar May 22 '23 10:05 catamphetamine

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

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

T-Lukashevich avatar May 25 '23 11:05 T-Lukashevich

Polish numbers has 9 digits, not 7.

LMarcinkowski avatar Apr 09 '24 20:04 LMarcinkowski