# 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:

- https://www.gob.pe/235-documento-nacional-de-identidad-dni

- https://es.wikipedia.org/wiki/Documento_Nacional_de_Identidad_(Perú)

    >>> 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)

  Calculate the possible check digits for the CUI.

stdnum.pe.cui.compact(number)

  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)

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

stdnum.pe.cui.to_ruc(number)

  Convert the number to a valid RUC.

stdnum.pe.cui.validate(number)

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