From d286b4eea84ff3c85d264e9161f3d81363fb0166 Mon Sep 17 00:00:00 2001 From: imsurya26 <219236223+imsurya26@users.noreply.github.com> Date: Sun, 22 Nov 2026 19:59:24 +0530 Subject: [PATCH] fix(fr_ssn): reject zero-padded 3-digit department codes --- src/validators/i18n/fr.py | 2 +- tests/i18n/test_fr.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/validators/i18n/fr.py b/src/validators/i18n/fr.py index 5552ef61..bf3830ae 100644 --- a/src/validators/i18n/fr.py +++ b/src/validators/i18n/fr.py @@ -16,7 +16,7 @@ def _ssn_pattern(): r"^([12])" # gender (1=M, 2=F) r"\s(\d{2})" # year of birth r"\s(0[1-9]|1[0-2])" # month of birth - r"\s(\d{2,3}|2[AB])" # department of birth + r"\s(\d{2}|97\d|2[AB])" # department of birth (only overseas ones have 3 digits) r"\s(\d{2,3})" # town of birth r"\s(\d{3})" # registration number r"(?:\s(\d{2}))?$", # control key (may or may not be provided) diff --git a/tests/i18n/test_fr.py b/tests/i18n/test_fr.py index f25c87c5..a9f7e1d9 100644 --- a/tests/i18n/test_fr.py +++ b/tests/i18n/test_fr.py @@ -41,6 +41,8 @@ def test_returns_true_on_valid_ssn(value: str): ("1 84 12 00 451 089",), # invalid department ("1 84 12 2C 451 089",), ("1 84 12 98 451 089",), # invalid department + ("1 84 12 075 76 481 95",), # zero-padded department + ("1 84 12 001 23 481",), # ("1 84 12 971 451 089",), # ? ], )