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

Accept lowercase IBANs in iban() by sayantanmandal1 · Pull Request #471 · 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
4 changes: 2 additions & 2 deletions src/validators/iban.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 @@ -8,8 +8,8 @@


def _char_value(char: str):
"""A=10, B=11, ..., Z=35."""
return char if char.isdigit() else str(10 + ord(char) - ord("A"))
"""A=10, B=11, ..., Z=35 (case-insensitive)."""
return char if char.isdigit() else str(10 + ord(char.upper()) - ord("A"))


def _mod_check(value: str):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_iban.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 @@ -13,6 +13,12 @@ def test_returns_true_on_valid_iban(value: str):
assert iban(value)


@pytest.mark.parametrize("value", ["gb82west12345698765432", "No9386011117947"])
def test_returns_true_on_valid_lowercase_iban(value: str):
"""Lowercase/mixed-case IBANs are accepted (the format regex is case-insensitive)."""
assert iban(value)


@pytest.mark.parametrize("value", ["GB81WEST12345698765432", "NO9186011117947"])
def test_returns_failed_validation_on_invalid_iban(value: str):
"""Test returns failed validation on invalid iban."""
Expand Down

Back | FazBrowse Home | New Git URL