-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Argentina(AR) number formatting and validation errors #24
Comments
This library is based on Google's libphonenumber (see PhoneNumberMetadata.xml). Could you check if it also contains this issue? |
Google's libphonenumber library has no problem. Java version(linked on libphonenumber) result with same AR phone number above. It returns 'italian_leading_zero' false but ex_phone_number does not (It returns true). I have been using Ruby version (https://github.com/daddyz/phonelib) and Golang version (https://github.com/nyaruka/phonenumbers) but they works fine with AR phone numbers. After comparing between two PhoneNumberMetadata.xml, there are quite some differences but I can't figure out which codes cause errors. |
Thanks for your research. |
I'm not sure I've done right but replacing current PhoneNumberMetadata.xml and PhoneNumberMetadataForTesting with Google's makes validation worse. AR phone numbers are still returned invalid and other countries either.
Moreover, there is an exception error on a UK phone number like below.
I think that replacing raw Metadata can't solve the problem. It might require some refactoring work. |
Yes, the data you provided above proves this.
I think you mean re-engineering or fixing. |
I thank you for suggesting but refactoring all country's code is out of my capability. I'll try to fix AR phone numbers errors first and request to pull later. :) |
In #27 the XML Metadata was updated. Could you check if this resolves your issues? |
Now we have: iex(3)> {:ok, phone_number} = ExPhoneNumber.parse("+54 114321-1200", "AR")
{:ok,
%ExPhoneNumber.Model.PhoneNumber{
country_code: 54,
country_code_source: nil,
extension: nil,
italian_leading_zero: nil,
national_number: 1143211200,
number_of_leading_zeros: nil,
preferred_domestic_carrier_code: nil,
raw_input: nil
}}
iex(4)> ExPhoneNumber.format(phone_number, :national)
"011 4321-1200"
iex(5)> ExPhoneNumber.is_valid_number?(phone_number)
true
iex(6)> {:ok, phone_number} = ExPhoneNumber.parse("011 4321-1200", "AR")
{:ok,
%ExPhoneNumber.Model.PhoneNumber{
country_code: 54,
country_code_source: nil,
extension: nil,
italian_leading_zero: true,
national_number: 1143211200,
number_of_leading_zeros: nil,
preferred_domestic_carrier_code: nil,
raw_input: nil
}}
iex(7)> ExPhoneNumber.format(phone_number, :national)
"01143211200"
iex(8)> ExPhoneNumber.is_valid_number?(phone_number)
false
iex(9)> {:ok, phone_number} = ExPhoneNumber.parse("555-555-5555", "US")
{:ok,
%ExPhoneNumber.Model.PhoneNumber{
country_code: 1,
country_code_source: nil,
extension: nil,
italian_leading_zero: nil,
national_number: 5555555555,
number_of_leading_zeros: nil,
preferred_domestic_carrier_code: nil,
raw_input: nil
}}
iex(10)> ExPhoneNumber.format(phone_number, :national)
"(555) 555-5555"
iex(11)> ExPhoneNumber.is_valid_number?(phone_number)
false
iex(12)> {:ok, phone_number} = ExPhoneNumber.parse("01131688131", "GB")
{:ok,
%ExPhoneNumber.Model.PhoneNumber{
country_code: 44,
country_code_source: nil,
extension: nil,
italian_leading_zero: nil,
national_number: 1131688131,
number_of_leading_zeros: nil,
preferred_domestic_carrier_code: nil,
raw_input: nil
}}
iex(13)> ExPhoneNumber.is_valid_number?(phone_number)
true |
And from your first post: iex(4)> {:ok, phone_number} = ExPhoneNumber.parse("+54 114321-1200", "AR")
{:ok,
%ExPhoneNumber.Model.PhoneNumber{
country_code: 54,
country_code_source: nil,
extension: nil,
italian_leading_zero: nil,
national_number: 1143211200,
number_of_leading_zeros: nil,
preferred_domestic_carrier_code: nil,
raw_input: nil
}}
iex(5)> ExPhoneNumber.format(phone_number, :national)
"011 4321-1200"
iex(6)> ExPhoneNumber.is_valid_number?(phone_number)
true
iex(7)> {:ok, phone_number} = ExPhoneNumber.parse("011 4321-1200", "AR")
{:ok,
%ExPhoneNumber.Model.PhoneNumber{
country_code: 54,
country_code_source: nil,
extension: nil,
italian_leading_zero: true,
national_number: 1143211200,
number_of_leading_zeros: nil,
preferred_domestic_carrier_code: nil,
raw_input: nil
}}
iex(8)> ExPhoneNumber.format(phone_number, :national)
"01143211200"
iex(9)> ExPhoneNumber.is_valid_number?(phone_number)
false
`` |
AR number still doesn't validate national formatted by itself like my original post.
But invalid GB number like 01131688131 is valid now. |
Thanks for checking. I now have also read it all and I confirm that we have still this bug here.
As we have recently updated the metadata (XML).
Now it should be much easier for you to try fixing the part of the code that is causing this issues. |
Okay, I'll try checking AR phone number format code. |
Was trying to see what was going on here so I was able to reproduce the original issue with iex. Then I added a test to
This test passes which is weird. I get a different result from parse() than in iex
Only difference is |
I've been using this library for a few years, but there are errors to format and validate Argentina numbers.
A formatted national number of AR by the library is invalid and not formatted again properly.
The only difference of result is 'italian_leading_zero: true' at second formatting.
Could you check it? Thanks. :)
Initial formatting
Second formatting
The text was updated successfully, but these errors were encountered: