stdnum.bic

BIC (ISO 9362 Business identifier codes).

An ISO 9362 identifier (also: BIC, BEI, or SWIFT code) uniquely identifies an institution. They are commonly used to route financial transactions.

The code consists of a 4 letter institution code, a 2 letter country code, and a 2 character location code, optionally followed by a three character branch code.

>>> validate('AGRIFRPP882')
'AGRIFRPP882'
>>> validate('ABNA BE 2A')
'ABNABE2A'
>>> validate('AGRIFRPP')
'AGRIFRPP'
>>> validate('AGRIFRPP8')
Traceback (most recent call last):
    ...
InvalidLength: ..
>>> validate('AGRIF2PP')  # country code can't contain digits
Traceback (most recent call last):
    ...
InvalidFormat: ..
>>> format('agriFRPP')  # conventionally caps
'AGRIFRPP'
stdnum.bic.compact(number)

Convert the number to the minimal representation. This strips the number of any surrounding whitespace.

stdnum.bic.format(number)

Reformat the number to the standard presentation format.

stdnum.bic.is_valid(number)

Check if the number provided is a valid BIC.

stdnum.bic.validate(number)

Check if the number is a valid routing number. This checks the length and characters in each position.