Skip to content

Commit

Permalink
Improve Phone Number Locale documentation (faker-ruby#2569)
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinballing authored and sudeeptarlekar committed Oct 7, 2022
1 parent d22cfb7 commit fc7ef3f
Showing 1 changed file with 20 additions and 3 deletions.
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

0 comments on commit fc7ef3f

Please sign in to comment.