arthurdejong / python-stdnum

A Python library to provide functions to handle, parse and validate standard numbers.
https://arthurdejong.org/python-stdnum/
GNU Lesser General Public License v2.1
484 stars 203 forks source link

IBAN Validation fails on Burundi, Djibouti, Russia, Somalia and Sudan #399

Closed rbetancourt27 closed 1 year ago

rbetancourt27 commented 1 year ago

I'm using stdnum to validate IBAN in my own repo so to test it before going on production I make some tests with a list of IBANs from this site: from this list I got 83 countries which 5 of them failed on testing. Is this expected? I tried other ways to validate these IBANs and are correct. My code is something like this:


from stdnum.iban import is_valid
# For example in this case a failing number would be DJ2110002010010409943020008
def test(self, number):
  assert is_valid(number=number, check_country=True)
arthurdejong commented 1 year ago

The DJ2110002010010409943020008 example seems to work fine:

>>> from stdnum import iban
>>> iban.validate('DJ2110002010010409943020008')
'DJ2110002010010409943020008'

Note that the DJ country code was only added to the IBAN registry last year and is only part of the 1.18 release of python-stdnum (see ee9dfdf).

rbetancourt27 commented 1 year ago

Updating my project to the latest version of python-stdnum got resolved for all countries except Somalia which is expected because I don't find it on IBAN registry and Burundi specifically I tried this IBANs: BI43220001131012345678912345 and SO061000001123123456789

DimitriPapadopoulos commented 1 year ago

I do find Somalia (SO) in the current Release 93 – February 2023 of the IBAN Registry.

Just need to run update/iban.py to update stdnum/isbn.dat. It would actually just add this line:

SO country="Somalia" bban="4!n3!n12!n"
DimitriPapadopoulos commented 1 year ago

Note that these IBAN numbers are invalid according to IBAN Checker or IBAN Calculator (“The checksum is incorrect.”):

BI43220001131012345678912345
DJ2110002010010409943020008
SO061000001123123456789

They're probably not up-to-date either, or might use python-stdnum :smile:

However, the official IBAN Checker does flag the Burundi IBAN (only) as incorrect (“IBAN Length is incorrect!”):

BI43220001131012345678912345
rbetancourt27 commented 1 year ago

Note that these IBAN numbers are invalid according to IBAN Checker or IBAN Calculator (“The checksum is incorrect.”):

BI43220001131012345678912345
DJ2110002010010409943020008
SO061000001123123456789

They're probably not up-to-date either, or might use python-stdnum smile

However, the official IBAN Checker does flag the Burundi IBAN (only) as incorrect (“IBAN Length is incorrect!”):

BI43220001131012345678912345

Thanks!