daddyz / phonelib

Ruby gem for phone validation and formatting using google libphonenumber library data
MIT License
1.04k stars 130 forks source link

Valid US Phone Number reporting as invalid #289

Closed tesshead-dox closed 5 months ago

tesshead-dox commented 7 months ago

I'm using phonelib v0.8.5 and trying to validate these three numbers:

2276310344
3696441631
3697958630

If I run them through the google libphonenumber that this gem is based on they appear as valid, however this phonelib gem states they're invalid. Area code 227 is Maryland and 369 is California. Adding a 1 to the number value did not fix the issue either.

example:

dev [10] pry(main)> Phonelib.parse(3696441631).valid_for_country?("US")
=> false
dev [11] pry(main)> Phonelib.parse(2276310344).valid_for_country?("US")
=> false
dev [12] pry(main)> Phonelib.parse(3697958630).valid_for_country?("US")
=> false
bergey commented 7 months ago

Is the script to import data from libphonenumber included in this repo? I also encountered issues with 227 numbers, and confirmed that it was recently added to libphonenumber. I'd like to update the data in my application, and open a PR here if you would like, but I don't see instructions in the readme. cc @jtangqt

nehresma commented 6 months ago

@bergey I haven't tried this, but I see that there is a rake task for updating: https://github.com/daddyz/phonelib/blob/master/lib/tasks/phonelib_tasks.rake

bergey commented 6 months ago

Thanks! That worked: https://github.com/daddyz/phonelib/pull/291

cdcooksey commented 5 months ago

Hello! 👋 Should this issue be closed since #291 has been merged?

tesshead-dox commented 5 months ago

These phone numbers work now, thank you all very much! Closing this issue.