mdomke / schwifty

IBAN parsing and validation
https://schwifty.readthedocs.io
MIT License
208 stars 83 forks source link

Wrong bank code regexp for GB IBANs #13

Closed 990px closed 4 years ago

990px commented 5 years ago
iban = IBAN("GB32ESSE40486562136016")
print(iban.bank_code)
'ESSE'

but should be 404865.

via https://en.wikipedia.org/wiki/International_Bank_Account_Number

GBkk bbbb ssss sscc cccc cc
b = BIC bank code
s = Bank and branch code (sort code)
c = Account number 

BIC bank code != bank code

mdomke commented 4 years ago

schwifty uses the official SWIFT specification that can be found here. If you look at section 2.25 of the IBAN registry linked from the SWIFT site you can see that the bank identifier is specified to be from position 1-4 of the BBAN and the branch identifier from 5-10.

BBAN = ESSE 404865 62136016
       ^  ^ ^    ^
       1  4 5    10

You have to acknowledge that schwifty uses a more generalized terminology for naming the different parts of an IBAN. The library doesn't know about any country specific wording (like sort code) nor does it take into account what additional national format might be applied to the different segments. So I think that considering the official specification schwifty's behavior is correct.