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

Faker.Phone.EnUs.phone() produces invalid phone numbers #414

Open
icecapp opened this issue Jul 16, 2021 · 2 comments
Open

Faker.Phone.EnUs.phone() produces invalid phone numbers #414

icecapp opened this issue Jul 16, 2021 · 2 comments

Comments

@icecapp
Copy link

icecapp commented Jul 16, 2021

This is most likely known/expected, but un(der?)documented.

After investigating why my test suite started sporadically failing, I discovered that Faker.Phone.EnUs.phone() often produces invalid numbers.

to demonstrate:

def test_faker_us_phone_numbers()
    Faker.Phone.EnUs.phone() 
    |> ExPhoneNumber.parse("US")
    |> ExPhoneNumber.is_valid_number?
end
iex(24)> Auth.test_faker_us_phone_numbers()
914/967-0531 is valid: true
iex(25)> Auth.test_faker_us_phone_numbers()
6237465431 is valid: true
iex(26)> Auth.test_faker_us_phone_numbers()
232-341-9001 is valid: false
iex(27)> Auth.test_faker_us_phone_numbers()
368.551.0368 is valid: false
iex(28)> Auth.test_faker_us_phone_numbers()
6063538095 is valid: true
iex(29)> Auth.test_faker_us_phone_numbers()
974.733.0044 is valid: false
iex(30)> Auth.test_faker_us_phone_numbers()
(963) 718-4753 is valid: false
iex(31)> Auth.test_faker_us_phone_numbers()
(949) 625-0125 is valid: true
iex(32)> Auth.test_faker_us_phone_numbers()
253.921.0196 is valid: true

For example, it can produce (963) 718-4753 which will never exist.

I understand maintaining an area code map is work, so perhaps just warning that this can conflict with validation libraries that do keep up-to-date (or try, as even "368" in iex(27) just got added May 2021)

@kristinabrueva
Copy link

Hi @icecapp thank you for your bug report. @igas I'd like to take a look at this one.

@igas
Copy link
Member

igas commented Jul 24, 2021

Thank you @Bruuu. Your help is much appreciated.

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

3 participants