stdnum.lei

LEI (Legal Entity Identifier).

The Legal Entity Identifier (LEI) is used to identify legal entities for use in financial transactions. A LEI is a 20-character alphanumeric string that consists of a 4-character issuing LOU (Local Operating Unit), 2 digits that are often 0, 13 digits to identify the organisation and 2 check digits.

More information:

>>> validate('213800KUD8LAJWSQ9D15')
'213800KUD8LAJWSQ9D15'
>>> validate('213800KUD8LXJWSQ9D15')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
stdnum.lei.compact(number)

Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding white space.

stdnum.lei.is_valid(number)

Check if the number is valid.

stdnum.lei.validate(number)

Check if the number is valid. This checks the length, format and check digits.