Repository navigation
fix(locale): only generate valid French postal codes - #3905
Merged
ST-DDT merged 1 commit intoJun 23, 2026
Merged
Conversation
The fr postcode definition was `['#####']`, which produces any 5-digit string, including the unassigned 00xxx, 96xxx and 99xxx ranges that fail postal-code validation. Build the patterns from the real department prefixes instead — metropolitan 01-95 and overseas 971-978/984/986-989 — mirroring the nl postcode fix (#3888). Closes #3550.
✅ Deploy Preview for fakerjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes French (fr) locale postal code generation so fakerFR.location.zipCode() only produces department-prefixed 5‑digit codes that fall within valid French postcode ranges, addressing validation failures reported in #3550.
Changes:
- Replace the
frlocale postcode definition with programmatically generated patterns covering metropolitan (01###–95###) and overseas (971##–978##,984##,986##–989##) prefixes. - Add a regression test that samples 1000 generated French zip codes and asserts they’re 5 digits and start with an allowed prefix.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/locales/fr/location/postcode.ts |
Generates postcode patterns from valid metropolitan and overseas department/territory prefixes to avoid invalid ranges. |
test/modules/location.spec.ts |
Adds a regression test ensuring fakerFR.location.zipCode() only yields 5-digit codes with valid French prefixes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #3905 +/- ##
=======================================
Coverage 98.84% 98.84%
=======================================
Files 913 914 +1
Lines 3209 3215 +6
Branches 574 574
=======================================
+ Hits 3172 3178 +6
Misses 33 33
Partials 4 4
🚀 New features to boost your workflow:
|
ST-DDT
approved these changes
Jun 22, 2026
Shinigami92
approved these changes
Jun 22, 2026
This was referenced Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3550.
Problem
The French (
fr) postcode definition is:#is replaced by any digit, sofakerFR.location.zipCode()generates any 5-digit string — including ranges that are not valid French postal codes and fail validation (e.g.validator.isPostalCode(code, 'FR')):00000–0099996000–9699999000–99999French postal codes start with a department prefix: metropolitan departments use
01–95, and the overseas departments/collectivities use971–978,984and986–989.Fix
Build the pattern array from the real department prefixes (metropolitan
01###–95###, overseas971##–978##,984##,986##–989##), so the unassigned00xxx/96xxx/99xxxranges are never produced. This mirrors the approach of the recently mergednlpostcode fix (#3888) — patterns are generated programmatically rather than hard-coded.Tests
Adds a regression test (
should only return valid department prefixes for fr locale) modeled on the existingnltest: over 1000 samples it asserts eachfakerFR.location.zipCode()is 5 digits and starts with a valid metropolitan (01–95) or overseas (971–978/984/986–989) prefix. It fails on the current definition (which produces00/96/99prefixes) and passes with this change. The fulllocationsuite (2417 tests) passes,pnpm run generate:localesreports no further changes, and ESLint/Prettier are clean.