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('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'
Traceback (most recent call last):
...
InvalidFormat: ..
Convert the number to the minimal representation. This strips the number of any surrounding whitespace.
Reformat the passed number to the standard format.
Checks to see if the number provided is a valid BIC. This checks the length and characters in each position.
Checks to see if the number provided is a valid routing number. This checks the length and characters in each position.