Skip to content

Invalid zip/postal codes when using locale fr_FR #3550

@bmenant

Description

@bmenant

Pre-Checks

Describe the bug

Maybe related to #1416 and #2390 but for a different locale FR, so I though a new ticket would be appropriate.

AFAIK, French post codes don’t follow extensive rules (there too many exceptions), but basically:

  1. They are always 5 digits long and may contain one leading 0.
  2. The first two or three digits are for the department code which goes from 01 to 95 plus the following three digits codes for overseas administrative areas: range from 971 to 978 plus 984, plus range from 986 to 989.

Notably, the following ranges are not valid french post codes, and none of them would pass this validation regexp:

  • 00000-00999
  • 96000-96999
  • 99000-99999

Minimal reproduction code

import { fakerFR as faker } from "@faker-js/faker";
import validator from 'validator';

console.log(validator.isPostalCode(faker.location.zipCode(), 'FR'));

Additional Context

The french post codes are maintained by “La Poste” but I’m not aware of any guidelines regarding their attribution: https://datanova.laposte.fr/datasets/laposte-hexasmal

Environment Info

System:
    OS: Linux 6.15 Fedora Linux 42 (Workstation Edition)
    CPU: (16) x64 13th Gen Intel(R) Core(TM) i7-1360P
    Memory: 4.51 GB / 13.35 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.16.0 - /usr/bin/node
    npm: 10.9.2 - /usr/bin/npm
    pnpm: 10.9.0 - /usr/bin/pnpm
  npmPackages:
    @faker-js/faker: ^9.8.0 => 9.8.0

Which module system do you use?

  • CJS
  • ESM

Used Package Manager

npm

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions