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

Only one country is returned in despite multiples matching #290

Open
aisler-ma opened this issue Nov 29, 2023 · 1 comment
Open

Only one country is returned in despite multiples matching #290

aisler-ma opened this issue Nov 29, 2023 · 1 comment

Comments

@aisler-ma
Copy link

Hi all together,

awesome library and works pretty good! However, I noticed one issue: if one defines multiple countries to check—either via default values or as parameter—the tool check for all countries where the phone number is valid/possible, however returns only the first valid result. This is okay, if one wants to guess and just want to get one single result. However, it is also kind of confusing, and I have a use case where I want to check if the given number is possible in more than one country.

I also found the responsible line of code: https://github.com/daddyz/phonelib/blob/master/lib/phonelib/phone_analyzer_helper.rb#L12

I was wondering why you do this and/or if there's a way to get a list of all countries where the number is valid*?

Thanks in advance and best!

  • I already tried .countries but it returned only one (the guessed) country.
@daddyz
Copy link
Owner

daddyz commented Mar 16, 2024

@aisler-ma interesting request, well, take this one as example, it works where there are multiple possibilities:

phone = Phonelib.parse("1 (787) 240-2750")
phone.countries # => ["AG", "AI", "AS", "BB", "BM", "BS", "CA", "DM", "DO", "GD", "GU", "JM", "KN", "KY", "LC", "MP", "MS", "PR", "SX", "TC", "TT", "US", "VC", "VG", "VI"]
phone.valid_countries # => ["PR"]

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

2 participants