FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Systematically enforce full-string matching for Indian PAN validation by mokoro10 · Pull Request #478 · python-validators/validators · GitHub

Repository navigation

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

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion src/validators/i18n/ind.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.fullmatch(r"[A-Z]{5}\d{4}[A-Z]{1}", value)
4 changes: 3 additions & 1 deletion tests/i18n/test_ind.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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", "ABCDE9999K "]
)
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)

Back | FazBrowse Home | New Git URL