Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/validators/i18n/fr.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
def _ssn_pattern():
"""SSN Pattern."""
return re.compile(
r"^([1,2])" # gender (1=M, 2=F)
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[A,B])" # department of birth
r"\s(\d{2,3}|2[AB])" # department of birth
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)
Expand Down
2 changes: 1 addition & 1 deletion src/validators/i18n/ind.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ def ind_pan(value: str):
(Literal[True]): If `value` is a valid PAN card number.
(ValidationError): If `value` is an invalid PAN card number.
"""
return re.match(r"[A-Z]{5}\d{4}[A-Z]{1}", value)
return re.match(r"^[A-Z]{5}\d{4}[A-Z]{1}$", value)
1 change: 1 addition & 0 deletions tests/i18n/test_fr.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def test_returns_true_on_valid_ssn(value: str):
(None,),
("",),
("3 84 12 76 451 089 46",), # wrong gender number
(", 84 12 76 451 089",), # comma is not a valid gender (regex char-class bug)
("1 84 12 76 451 089 47",), # wrong control key
("1 84 00 76 451 089",), # invalid month
("1 84 13 76 451 089",), # invalid month
Expand Down
4 changes: 3 additions & 1 deletion tests/i18n/test_ind.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def test_returns_true_on_valid_ind_pan(value: str):
assert ind_pan(value)


@pytest.mark.parametrize("value", ["ABC5d7896B", "417598346012", "AaaPL1234C"])
@pytest.mark.parametrize(
"value", ["ABC5d7896B", "417598346012", "AaaPL1234C", "ABCDE9999KEXTRA"]
)
def test_returns_failed_validation_on_invalid_ind_pan(value: str):
"""Test returns failed validation on invalid ind pan."""
assert isinstance(ind_pan(value), ValidationError)