You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not really sure if this is a bug, but it's strange behavior and diverges from libphonenumber's behavior. For the phone number (787) 240-2750, which is a Puerto Rican phone number, libphonenumber with the default country set to US parses like this:
****Parsing Result:****
{"country_code":1,"national_number":7872402750,"raw_input":"(787) 240-2750","country_code_source":20}
****Validation Results:****
Result from isPossibleNumber(): true
Result from isValidNumber(): true
Result from isValidNumberForRegion(): false
Phone Number region: PR
Result from getNumberType(): FIXED_LINE_OR_MOBILE
phonelib, however does not give the same validation results,:
@james-caresnap the issue here is that when you pass country code, phonelib tries to guess the country, actually it always tries to guess, that's why you are getting valid PR result for number starting with 1. When you define default country US and pass without country code, it tries to parse for US only and if failed, tries to guess country, but since no 1 in the beginning it tries to guess for 787 and fails. You can define several default countries and then it will work:
Phonelib version: 0.7.0
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
I'm not really sure if this is a bug, but it's strange behavior and diverges from
libphonenumber
's behavior. For the phone number(787) 240-2750
, which is a Puerto Rican phone number,libphonenumber
with the default country set toUS
parses like this:phonelib
, however does not give the same validation results,:However, it behaves the same as
libphonenumber
if you reformat ine164
or prefix with the1
international calling code:May be related to issue #220.
The text was updated successfully, but these errors were encountered: