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')
>>> validate('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

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


Reformat the number to the standard presentation format.


Check if the number provided is a valid BIC.


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