Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fix(i18n/ind): anchor ind_pan so trailing characters are rejected
ind_pan used re.match(r"[A-Z]{5}\d{4}[A-Z]{1}", ...) with no trailing $,
so any string starting with a valid PAN was accepted -- e.g.
ind_pan('ABCDE9999KEXTRA') returned a match. Anchor the pattern with
^...$, matching the ind_aadhar style just above it.
  • Loading branch information
Jordan-Bourillot committed Jun 24, 2026
commit f0eae3d7708e7390d5584e9140dd8d6d63994947
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)
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)