Closed abhatia1176 closed 2 months ago
From what I understand, and it's often the desirable behavior, the provided country is just a fallback for phone numbers not in an international format. If a phone number is a valid international phone number, you often don't want to reject it. Say you have a customer traveling from Jamaica, they have a valid phone number, you can serve them even in US.
@abhatia1176 @andreyvit Fixed. Please use v0.1.8
The library incorrectly identifies an invalid USA phone number as Jamaica number.
Example:
phonenumber.ParseWithLandLine("+1 289 2999", "US")
Expected output: "". Actual output: +12892999. I believe that since the length matched Jamaica's number length (7), it matched it with the country Jamaica.
The issue is that despite the country being provided correctly in the input, the function tries to identify the ISO3166 by Number in the following lines, and the GetISO3166ByNumber function matches with Jamaica. I did not follow why the library tried to retrieve ISO3166 by phone number when the correct country (US) was already provided as input.