Faker.Phone.EnUs.phone() produces invalid phone numbers
- Dominant language
- Elixir
- Stars
- 1.2k
- Forks
- 261
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 13
Description
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:
```elixir
def test_faker_us_phone_numbers()
Faker.Phone.EnUs.phone()
|> ExPhoneNumber.parse("US")
|> ExPhoneNumber.is_valid_number?
end
```
```elixir
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)
Contributor guide
Research direction
Start with Faker.Phone.EnUs.phone() and reproduce the examples by validating its output with ExPhoneNumber.parse("US") and ExPhoneNumber.is_valid_number?. Decide whether the expected result is valid US numbers or an explicit warning about area-code accuracy; done means the chosen behavior is documented or consistently meets the stated validation expectation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elixir
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100