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(location): fix US ZIP code anomalies for zipCode({state}) #3180

Merged
merged 2 commits into from
Oct 16, 2024

Conversation

matthewmayer
Copy link
Contributor

@matthewmayer matthewmayer commented Oct 13, 2024

fix #3169

takes advantage of the new syntax allowed by #3170

Fixes issues where fakerEN_US.zipCode({state:"XX"}) would give a ZIP code in the wrong state, due to various anomalies:

  • don't allow AR to return 72643 as its in MO
  • don't allow ID to return 83414 as its in WY
  • don't allow HI to return 96799 as its in AS (note AS is American Samoa, not a state)
  • don't allow PR to return 008xx as its in VI (note PR is Puerto Rico and VI is Virgin Islands, neither are states)
  • refactor the FL patterns to exclude the 340xx AA military block, and tighten the validity for other blocks

After this PR there should be no cases where fakerEN_US.zipCode({state:"XX"}) gives a valid ZIP in another state, although there are still many cases where it gives an invalid ZIP (but this is impossible to prevent without shipping a list of every possible ZIP).

Copy link

netlify bot commented Oct 13, 2024

Deploy Preview for fakerjs ready!

Name Link
🔨 Latest commit 545e7c2
🔍 Latest deploy log https://app.netlify.com/sites/fakerjs/deploys/670f8b2fc8daaa0008851525
😎 Deploy Preview https://deploy-preview-3180.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Oct 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.96%. Comparing base (98d1dc0) to head (545e7c2).
Report is 1 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff            @@
##             next    #3180    +/-   ##
========================================
  Coverage   99.96%   99.96%            
========================================
  Files        2798     2798            
  Lines      227328   227367    +39     
  Branches      577      957   +380     
========================================
+ Hits       227255   227298    +43     
+ Misses         73       69     -4     
Files with missing lines Coverage Δ
src/locales/en_US/location/postcode_by_state.ts 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

@matthewmayer matthewmayer marked this pull request as ready for review October 13, 2024 16:38
@matthewmayer matthewmayer requested a review from a team as a code owner October 13, 2024 16:38
@matthewmayer matthewmayer self-assigned this Oct 13, 2024
@matthewmayer matthewmayer added p: 1-normal Nothing urgent m: location Something is referring to the location module c: bug Something isn't working c: locale Permutes locale definitions labels Oct 13, 2024
@ST-DDT ST-DDT requested review from a team October 13, 2024 17:11
@ST-DDT ST-DDT enabled auto-merge (squash) October 16, 2024 09:45
@ST-DDT ST-DDT merged commit df59724 into faker-js:next Oct 16, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working c: locale Permutes locale definitions m: location Something is referring to the location module p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZIP code anomalies
3 participants