diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2018-10-09 22:07:33 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2018-10-09 22:08:53 +0200 |
commit | 58ea7b20682021e9ed91587adb484534fb7a768f (patch) | |
tree | 18ae60c64d9314d5965878689a1950463d1c1c0a | |
parent | 54c36507220a9f39a14fade446d779315e37a270 (diff) |
Fix issue with minimal IBAN
This ensures that an IBAN with a missing bban part and unknown country
code (while still having a valid MOD 97,10 checksum) is considered
valid.
Closes https://github.com/arthurdejong/python-stdnum/issues/84
-rw-r--r-- | stdnum/iban.py | 2 | ||||
-rw-r--r-- | tests/test_iban.doctest | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/stdnum/iban.py b/stdnum/iban.py index 09c8fdb..bbf181b 100644 --- a/stdnum/iban.py +++ b/stdnum/iban.py @@ -106,7 +106,7 @@ def validate(number, check_country=True): info = _ibandb.info(number) # check if the bban part of number has the correct structure bban = number[4:] - if not _struct_to_re(info[0][1].get('bban', '')).match(bban): + if not _struct_to_re(info[0][1].get('bban', '-')).match(bban): raise InvalidFormat() # check the country-specific module if it exists if check_country: diff --git a/tests/test_iban.doctest b/tests/test_iban.doctest index eef1948..0625fb1 100644 --- a/tests/test_iban.doctest +++ b/tests/test_iban.doctest @@ -25,6 +25,15 @@ really useful as module documentation. >>> from stdnum import iban +Test for IBAN corner case that happens when the bban part is empty, the +country code is unknown and the checksum is still valid. + +>>> iban.validate('0001') +Traceback (most recent call last): + ... +InvalidFormat: ... + + These should all be valid numbers and are from the IBAN REGISTRY as sample numbers: |