LouisMazel / vue-phone-number-input

A phone number input made with Vue JS (format & valid phone number)
https://louismazel.github.io/vue-phone-number-input
MIT License
606 stars 152 forks source link

(BUG) status of isValid is turning into TRUE even if it's not correct #127

Open abernados opened 3 years ago

abernados commented 3 years ago

Describe the bug

When you select the Philippines and input a number, the status of isValid is turning into TRUE even if it's not correct. Sometimes isValid became TRUE if you entered 6 and 8 digits.

Steps to reproduce

  1. Go to https://louismazel.github.io/vue-phone-number-input/
  2. Test the basic usage
  3. Select PH/Philippines as a country
  4. Input 6 random numbers and isValid will become TRUE. Also when you input 8 random numbers, isValid will become TRUE.

Expected behavior

When you enter a number which is not the same format as the placeholder/hint above, it will not return the param, isValid, TRUE. This is the correct format of the phone number: image

Screenshots

I entered 6 random numbers: image

I entered 8 random numbers: image

mizhon commented 3 years ago

Hi, I search on this for a while, and find the issuse is actually caused by the dependency lib: "libphonenumber-js" It use the "parsePhoneNumberFromString" mehtod to get the parsing result and it's isValid() method is incorrect. https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/19 image

jaawaad commented 3 years ago

Has anyone found a solution to this problem?

isokosan commented 3 years ago

Try importing libphonenumber-js/max instead of libphonenumber-js, as that includes the minimum version which does not check some valid cases.