leodido / i18n.phonenumbers.js

Parse, format, and validate international phone numbers through libphonenumber
18 stars 14 forks source link

isValid/PossibleNumber(ForRegion) triggering an Exception #31

Open linqFR opened 7 years ago

linqFR commented 7 years ago

Hello

While trying to use i18n as 'as you type' formatter, i got an exception with typing '+xx' number for France:

As I am testing the string I got :

Uncaught The string supplied did not seem to be a phone number i18n.phonenumbers/min.js:384

which is what I want to test and get 'false' from functions isValid/PossibleNumber(ForRegion) but instead it throws an Exception stopping the code !

leodido commented 7 years ago

Please provide a reproducible snippet of code.

In the meantime I've done some tests (simply using the demo page) ..

leodido.i18n.PhoneNumbers.isPossibleNumber('+xx123456789', 'FR') // > false
leodido.i18n.PhoneNumbers.isPossibleNumberWithReason('+xx123456789') // > 3
leodido.i18n.PhoneNumbers.RESULT.getKeyByValue(3) // > TOO_LONG
leodido.i18n.PhoneNumbers.isValidNumber('+xx123456789') // > false
leodido.i18n.PhoneNumbers.isValidNumberForRegion('+xx123456789') // > false
linqFR commented 7 years ago

well maybe if you try '+xx', x being a number ! so let's try +61 or +14 or +95 or +23