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

Improve Phone Number Locale documentation #2569

Merged
merged 1 commit into from
Sep 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions doc/default/phone_number.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ This formatter will return one of the following formats:
* +33333333333333
* +3333333333333

## Locale
By setting the locale, you can generate a phone number with a valid area code in that locale (and valid exchange code, where relevant).

### Locales with area codes
```Faker::Config.locale = 'en-US'
Faker::Config.locale = 'en-CA'
Faker::Config.locale = 'fr-CA'
Faker::Config.locale = 'en-AU'
Faker::Config.locale = 'pt-BR'
```

### Locales with exchange codes
```Faker::Config.locale = 'en-US'
Faker::Config.locale = 'en-CA'
Faker::Config.locale = 'fr-CA'
```

## Usage

Don't let the example output below fool you -- any format can be returned at random.
Expand All @@ -43,15 +60,15 @@ Faker::PhoneNumber.cell_phone #=> "(186)285-7925"
Faker::PhoneNumber.cell_phone_in_e164 #=> "+944937040625"

# NOTE NOTE NOTE NOTE
# For the 'US only' methods below, first you must do the following:
# For these two 'Locale-specific' methods, first you must set a relevant locale as mentioned above, such as:
Faker::Config.locale = 'en-US'
# or for Canada
Faker::Config.locale = 'en-CA'

# US only
# Locale-specific
Faker::PhoneNumber.area_code #=> "201"

# US only
# Locale-specific
Faker::PhoneNumber.exchange_code #=> "208"

# Keyword arguments: length
Expand Down