Skip to content

Commit

Permalink
docs: update with notes about validity for zips (#2963)
Browse files Browse the repository at this point in the history
* docs: update with notes about validity for zips

* update with locale
  • Loading branch information
garrettgregor authored Jun 11, 2024
1 parent 88283de commit 7d14d42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions doc/default/address.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ Faker::Address.mail_box #=> "PO Box 123"

Faker::Address.community #=> "University Crossing"

#note: #zip_code will return a random string in zipcode format; may or may not be a valid zip for locale
Faker::Address.zip_code #=> "58517" or "23285-4905"

#note: #zip will return a random string in zipcode format; may or may not be a valid zip for locale
Faker::Address.zip #=> "58517" or "66259-8212"

#note: #postcode will return a random string in postcode format; may or may not be a valid zip for locale
Faker::Address.postcode #=> "76032-4907" or "58517"

Faker::Address.time_zone #=> "Asia/Yakutsk"
Expand Down
4 changes: 2 additions & 2 deletions lib/faker/default/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ def zip_code(state_abbreviation: '')
return numerify(letterified_string, leading_zero: true)
end

# provide a zip code that is valid for the state provided
# see http://www.fincen.gov/forms/files/us_state_territory_zip_codes.pdf
# provide a zip code that may be valid for the state provided
# note: zip code may appear in the correct format for the state provided but may not be an actual state zip.
bothify(fetch("address.postcode_by_state.#{state_abbreviation}"))
end

Expand Down

0 comments on commit 7d14d42

Please sign in to comment.