Site Valid Number indication does not take selected country into account
Opened this issue · 3 comments
In phoneformat.com/js/source.js#L67 you test the phone input as being valid or not which does not take into account the selected country. Wouldn't it be more correct to test the resulting E164 number for this validation?
(great work on this project btw thanks 😃)
You bring up a great point. libphonenumber has another method isValidNumberForRegion which does take into account the selected country. https://code.google.com/p/libphonenumber/source/browse/trunk/javascript/i18n/phonenumbers/phonenumberutil.js#2672
I will add this new method later on today. Thank you for the kind words, it motivates me!
Indeed that seems more logical
There's another issue as well with regards to the "International" display.
Test case: 149133000 with country France.
When trying this on the libphonenumber demo site it returns the correct results.
_Parsing Result:_
{"country_code":33,"national_number":149133000,"raw_input":"149133000","country_code_source":20,"preferred_domestic_carrier_code":""}_Validation Results:_
Result from isPossibleNumber(): true
Result from isValidNumber(): true
Result from isValidNumberForRegion(): true
Phone Number region: FR
Result from getNumberType(): FIXED_LINE*_Formatting Results:_*
E164 format: +33149133000
Original format: 1 49 13 30 00
National format: 01 49 13 30 00
International format: +33 1 49 13 30 00
Out-of-country format from US: 011 33 1 49 13 30 00
Out-of-country format from Switzerland: 00 33 1 49 13 30 00