faker icon indicating copy to clipboard operation
faker copied to clipboard

Call fake.zipcode_in_state('AZ'), the return zipcode not valid AZ zip code

Open pengdada00100 opened this issue 1 year ago • 3 comments

  • Faker version: 24.0
  • OS:Macos

Call fake.zipcode_in_state('AZ'), the return zipcode not valid AZ zip code

Steps to reproduce

Run code: `from faker import Faker

if name == "main": fake = Faker() f = fake.zipcode_in_state('AZ') print(f)`

get 85800 which not in AZ state

Expected behavior

The zip code should in AZ

Actual behavior

The zipcode not in AZ

pengdada00100 avatar Mar 18 '24 06:03 pengdada00100

The implementation is in https://github.com/joke2k/faker/blob/250fa19baf01aa2289afe44b07225f785cf536c5/faker/providers/address/en_US/init.py#L543-L547 Feel free to submit a corresponding PR.

stefan6419846 avatar Mar 18 '24 07:03 stefan6419846

  • Faker version: 24.0
  • OS:Macos

Call fake.zipcode_in_state('AZ'), the return zipcode not valid AZ zip code

Steps to reproduce

Run code: `from faker import Faker

if name == "main": fake = Faker() f = fake.zipcode_in_state('AZ') print(f)`

get 85800 which not in AZ state

Expected behavior

The zip code should in AZ

Actual behavior

The zipcode not in AZ

@pengdada00100 You can add locale to your code For example:

if __name__ == "__main__":
    fake = Faker("en_US") # add locale
    f = fake.zipcode_in_state('AZ')
    print(f)

lozik4 avatar Mar 19 '24 16:03 lozik4

I think this issue can be closed. The problem is that not all 5 digits are valid ZIP codes, and faker can't create valid ones without checking them from a database/API.

However, 85775 is Tucson, AZ and 85901 is Show Low, AZ, so the randomly created 85800 is in the correct range for AZ.

tonyk232 avatar Apr 06 '24 20:04 tonyk232

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Jul 06 '24 01:07 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jul 20 '24 01:07 github-actions[bot]