-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
phone_number can generate invalid US numbers #24
Comments
@haxney all you need to do here is set Faker::Config.locale to 'en-us' and add in valid us phone number formats to that i18n locale file as it's not yet implemented ;) |
👍 for a Phony/Faker crossover. |
For anyone running into this issue today, you just need |
What I did in an application with heavy phone use was Phony validation, as @toobulkeh mentioned. |
I did: phone_number do
begin
phone_number = Faker::PhoneNumber.phone_number_with_country_code
phonelib = Phonelib.parse(phone_number)
end until phonelib.valid? && phonelib.possible?
phone_number
end |
for those hitting this issue, I still see it with the en-US locale and recent versions of phonelib
the issue seems to be related to extension numbers, as faker will generate stuff with a literal "x" in it, like You can tell phonelib to accept these, and then it should work
|
Are those numbers even valid? I will open an issue on phonelib |
|
I'm using the phone library to parse phone numbers, and it does not allow invalidly-formatted phone numbers. An example is that US area codes are not allowed to start with
1
(and0
, I believe), but Faker will generate numbers with these invalid area codes. Would it be possible to restrict the range of numbers used in generating area codes for Faker phone numbers?The text was updated successfully, but these errors were encountered: