nyaruka / phonenumbers

GoLang port of Google's libphonenumber library
MIT License
1.25k stars 148 forks source link

Standardize country code letter case before parsing. #130

Closed PreciousNyasulu closed 1 year ago

PreciousNyasulu commented 1 year ago

converts the country code to upper case before parsing.

rowanseymour commented 1 year ago

This library is a port of the Google phonenumbers library and as such we want functionality to match that library as closely as possible. I just checked and it seems the official library requires country codes to be correctly uppercased, so best that maintain that behavior here as well.

>>> import phonenumbers
>>> phonenumbers.parse("0979111111", "ec")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/rowanseymour/Nyaruka/rapidpro/.venv/lib/python3.10/site-packages/phonenumbers/phonenumberutil.py", line 2927, in parse
    raise NumberParseException(NumberParseException.INVALID_COUNTRY_CODE,
phonenumbers.phonenumberutil.NumberParseException: (0) Missing or invalid default region.