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

en-US locale incorrectly includes Canadian area code 226 #698

csyager opened this issue Jan 20, 2022 · 1 comment

en-US locale incorrectly includes Canadian area code 226 #698

csyager opened this issue Jan 20, 2022 · 1 comment


Copy link

csyager commented Jan 20, 2022

Describe the bug
The en-US locale en-US.faker.phone_number.area_code array (see src/main/resources/en-US.yml, line 41022) includes area code 226, which is a Canadian area code. Phone numbers generated by java-faker with this area code will not pass validation checks asserting that they are valid US numbers.

To Reproduce
Since these are randomly generated phone numbers, reproducing this issue is difficult. However using a phone number with this area code that java-faker could generate, for example +12262011212, and Google's libphonenumber, you can demonstrate that this number does not pass validation. See example in Kotlin below:

fun validatePhoneNumber() {
    val phoneNumber = "+12262011212"
    val phoneUtil = PhoneNumberUtil.getInstance()
    val proto = phoneUtil.parse(phoneNumber, "US")
    println(phoneUtil.isValidNumberForRegion(proto, "US"))
Output:  false

Running this function with a phone number of +12252011212, which has the valid area code 225, instead prints true.

Expected behavior
When set with the en-US locale, java-faker should not generate phone numbers with area code 226, as they are not valid US numbers.


  • OS: OSX 11.5.2
  • JDK: openjdk version 11.0.11
  • Faker Version 1.0.2

Additional context
faker-ruby/faker had this same issue and resolved it in May 2021: faker-ruby/faker#2321

The North American Numbering Plan Administration, who sets the area codes, has this list published on their website, which lists 226 as an area code for Ontario.

bodiam added a commit to datafaker-net/datafaker that referenced this issue Jan 22, 2022
Copy link

bodiam commented Jan 24, 2022

@csyager thanks for letting me know. I've fixed it Datafaker here (datafaker-net/datafaker@8d12a6a#diff-34e7864f8f8fc27d914377b08ad3b1fc2feb7d9496beae7e3ce7886f2d535332), along with a few other issues which were fixed in faker-ruby, and I've fixed a few more telephone issues on the way. Thanks for the Kotlin code sample, that was very helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants