stdnum.pe.cui

CUI (Cédula Única de Identidad, Peruvian identity number).

The Cédula Única de Identidad (CUI) is the unique identifier for persons that appears on the Documento Nacional de Identidad (DNI), the national identity document of Peru. The number consists of 8 digits and an optional extra check digit.

More information:

>>> validate('10117410')
'10117410'
>>> validate('10117410-2')
'101174102'
>>> validate('10117410-3')  # invalid check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> to_ruc('10117410-2')
'10101174102'
stdnum.pe.cui.calc_check_digits(number: str) str

Calculate the possible check digits for the CUI.

stdnum.pe.cui.compact(number: str) str

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

stdnum.pe.cui.is_valid(number: str) bool

Check if the number provided is a valid CUI. This checks the length, formatting and check digit.

stdnum.pe.cui.to_ruc(number: str) str

Convert the number to a valid RUC.

stdnum.pe.cui.validate(number: str) str

Check if the number provided is a valid CUI. This checks the length, formatting and check digit.