Skip to content

Systematically enforce full-string matching for Indian PAN validation - #478

Open
mokoro10 wants to merge 1 commit into
python-validators:masterfrom
mokoro10:fix/pan-validator-trailing-data-anchor
Open

Systematically enforce full-string matching for Indian PAN validation#478
mokoro10 wants to merge 1 commit into
python-validators:masterfrom
mokoro10:fix/pan-validator-trailing-data-anchor

Conversation

@mokoro10

Copy link
Copy Markdown

Replace prefix-oriented regex matching in the Indian PAN validator with re.fullmatch, ensuring that otherwise valid PAN prefixes followed by arbitrary trailing data are rejected.

ind_pan() currently uses re.match(r"[A-Z]{5}\\d{4}[A-Z]{1}", value), which is not end-anchored. Any string that merely begins with a syntactically valid 10-character PAN is accepted, even with arbitrary trailing characters (e.g. "ABCDE9999Kextra", "ABCDE9999K "). The neighboring ind_aadhar validator in the same file is already end-anchored, so this looks like an unintentional asymmetry rather than deliberate prefix matching.

This is a small, low-risk change (one line) plus two additional regression cases added to the existing parametrized test in tests/i18n/test_ind.py. Full test file passes locally (12/12).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant