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

Fix bug on phone number generator for en-US locale caused by incorrect .yml file structure #2924

Merged
merged 1 commit into from
Mar 28, 2024

Commits on Mar 28, 2024

  1. Move en-US.yml's cell_phone entry to the correct position

    `PhoneNumber.cell_phone` expects an i18n key of `cell_phone.formats`,
    but the en-US.yml file currently has `faker.phone_number.cell_phone`
    instead of `faker.cell_phone`.
    
    The result of that mismatch is that `cell_phone` will ignore the defined
    formats, and potentially generate invalid US numbers (e.g. those with an
    area code beginning with 1) when the locale is en-US.
    
    31d99d1 reworked YAML structure and
    appears to have inadvertently moved the key.
    
    You can see the change in US number behavior in a console:
    
      Faker::Config.locale = "en-US"
      Faker::PhoneNumber.translate("faker.cell_phone.formats")
    
    On 3.3.0 this returns
    
      ["###-###-####", "(###) ###-####", "###.###.####", "### ### ####"]
    
    because it's the fallback value within the `en` (not `en-US`) locale
    file. The correct value should be the formats outdented in this commit.
    aprescott committed Mar 28, 2024
    Configuration menu
    Copy the full SHA
    c7772c6 View commit details
    Browse the repository at this point in the history