Skip to content

Commit d286b4e

Browse files
committed
fix(fr_ssn): reject zero-padded 3-digit department codes
1 parent 22786cc commit d286b4e

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎src/validators/i18n/fr.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def _ssn_pattern():
1616
r"^([12])" # gender (1=M, 2=F)
1717
r"\s(\d{2})" # year of birth
1818
r"\s(0[1-9]|1[0-2])" # month of birth
19-
r"\s(\d{2,3}|2[AB])" # department of birth
19+
r"\s(\d{2}|97\d|2[AB])" # department of birth (only overseas ones have 3 digits)
2020
r"\s(\d{2,3})" # town of birth
2121
r"\s(\d{3})" # registration number
2222
r"(?:\s(\d{2}))?$", # control key (may or may not be provided)

‎tests/i18n/test_fr.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def test_returns_true_on_valid_ssn(value: str):
4141
("1 84 12 00 451 089",), # invalid department
4242
("1 84 12 2C 451 089",),
4343
("1 84 12 98 451 089",), # invalid department
44+
("1 84 12 075 76 481 95",), # zero-padded department
45+
("1 84 12 001 23 481",),
4446
# ("1 84 12 971 451 089",), # ?
4547
],
4648
)

0 commit comments

Comments
 (0)