Skip to content

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

@csyager

Description

@csyager

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.

Versions:

  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions