Skip to content
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

Update PhoneNumberMetadata #43

Open
szymon-jez opened this issue Apr 3, 2021 · 10 comments
Open

Update PhoneNumberMetadata #43

szymon-jez opened this issue Apr 3, 2021 · 10 comments
Assignees

Comments

@szymon-jez
Copy link
Member

Refs #42, #39, #33

Problem

The library uses outdated metadata. Therefore it is not validating/formatting some numbers right.

Solution

To upgrade the metadata it is also necessary to upgrade the code.

@josemrb
Copy link
Collaborator

josemrb commented Apr 6, 2021

Tasks

Add method getLengthOfGeographicalAreaCode

Implement function

and corresponding test

Add method getLengthOfNationalDestinationCode

Implement function

and corresponding test

Add method getCountryMobileToken

Implement function

and corresponding test

Add method isPossibleNumberForType

Implement function

and corresponding tests

Add method isPossibleNumberForTypeWithReason

Implement function

and corresponding tests

Add method truncateTooLongNumber

Implement function

and corresponding test

Add method canBeInternationallyDialled

Implement function

and corresponding test

Add method isAlphaNumber

Implement function

and corresponding test

Review method testNumberLengthForType_

Review helper function

Review method parse

Review function

and add new tests

Current Test Suite

  • Fix currently failing tests (250 tests, 12 failures)

@icecapp
Copy link

icecapp commented Jul 18, 2021

I've been running some tests and noticed an area code that was recently introduced in Alberta, Canada, that would fail the is_valid_number?/1 test.

iex(33)> {:ok, parsed} = ExPhoneNumber.parse("368.551.0368", "CA") 
{:ok,
 %ExPhoneNumber.Model.PhoneNumber{
   country_code: 1,
   country_code_source: nil,
   extension: nil,
   italian_leading_zero: nil,
   national_number: 3685510368,
   number_of_leading_zeros: nil,
   preferred_domestic_carrier_code: nil,
   raw_input: nil
 }}

(fails with "US" as well)

This js port validates the previous number properly (see sandbox)

OP stated:

To upgrade the metadata it is also necessary to upgrade the code.

My question: why are all methods listed above needed in order to get the metadata up-to-date? And would that mean that is_valid_number?/1 is broken until all this is implemented?

@josemrb
Copy link
Collaborator

josemrb commented Jul 19, 2021

My question: why are all methods listed above needed in order to get the metadata up-to-date?

Because they are needed to handle the newer metadata.

And would that mean that is_valid_number?/1 is broken until all this is implemented?

Yes, although it isn't broken, just outdated.

You could build the current develop branch as it contains the latest metadata (8.12.27) but it will fail if it comes across a new case that has not been implemented (239 tests, 8 failures)

iex(1)> {:ok, parsed} = ExPhoneNumber.parse("368.551.0368", "CA")
{:ok,
  %ExPhoneNumber.Model.PhoneNumber{
              country_code: 1,
              country_code_source: nil,
              extension: nil,
              italian_leading_zero: nil,
              national_number: 3685510368,
              number_of_leading_zeros: nil,
              preferred_domestic_carrier_code: nil,
              raw_input: nil
  }}
iex(2)> ExPhoneNumber.is_valid_number?(parsed)
true

As the metadata changes every 2-3 weeks, it is very likely that you will find a phone number that does not pass the validation even if it is "real". See Falsehoods About Phone Numbers.

@icecapp
Copy link

icecapp commented Jul 19, 2021

Thanks for the quick reply.

Just wondering, in general, what is the delay for mirroring official libphonenumber, as the client implementation I'm using of libphonenumber accepts certain numbers that ex_phone_number doesn't.

Nevertheless respect, kudos and many thanks for developing, open-sourcing and maintaining this library. 🤜

@szymon-jez
Copy link
Member Author

szymon-jez commented Jul 20, 2021

Just wondering, in general, what is the delay for mirroring official libphonenumber

https://github.com/socialpaymentsbv/ex_phone_number/blob/master/README.md states the currently used metadata version. This should give you enough information to see the delay.

@josemrb
Copy link
Collaborator

josemrb commented Jul 20, 2021

Nothing in particular, I haven't had enough time, pending changes have accumulated and the code is complex in some parts, although the latter is the result of following the upstream project since this is almost a function by function port.

@jasminpatel28
Copy link

When are you planning to release new version?
I have built from develop branch and looks problem solved for me but its not working fine with v0.2.1
Earlier Its not able to validate Columbian (CO) number with area code (324)

@szymon-jez
Copy link
Member Author

szymon-jez commented Oct 18, 2021

When are you planning to release new version?

There is no release date set. As you can see the work was started many months ago and might be considered slow, but it is steady moving forward thanks to @josemrb and recently also @tomciopp. I think that – because of to the clear plan laid out above by Jose – others might also join this effort.

I have built from develop branch and looks problem solved for me but its not working fine with v0.2.1 Earlier Its not able to validate Columbian (CO) number with area code (324)

I think that develop should not break anything but rather improve things, so if you need any feature from it that is not working in the latest release then I would go for it.

@jasminpatel28
Copy link

When are you planning to release new version?

There is no release date set. As you can see the work was started many months ago and might be considered slow, but it is steady moving forward thanks to @josemrb and recently also @tomciopp. I think that – because of to the clear plan laid out above by Jose – others might also join this effort.

I have built from develop branch and looks problem solved for me but its not working fine with v0.2.1 Earlier Its not able to validate Columbian (CO) number with area code (324)

I think that develop should not break anything but rather improve things, so if you need any feature from it that is not working in the latest release then I would go for it.

Thanks @szymon-jez for your reply.
I need lib to support changes happened to Columbian number structure and that's available in develop branch. I saw metadata file is updated.

@lohayon
Copy link

lohayon commented Nov 24, 2021

I join here the conversation:
The library uses outdated metadata. Therefore it is not validating/formatting some numbers right.
We also encountered this issue. We potentially want to add some prefixes before the official document is released with these prefixes.
I wonder if it would be possible to make the document path dynamic and configurable.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants