stdnum.br.cpf

CPF (Cadastro de Pessoas Físicas, Brazilian national identifier).

The Cadastro de Pessoas Físicas is the Brazilian identification number assigned to individuals for tax purposes. The number consists of 11 digits and includes two check digits.

More information:

>>> validate('390.533.447-05')
'39053344705'
>>> validate('231.002.999-00')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('390.533.447=0')  # invalid delimiter
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> format('23100299900')
'231.002.999-00'
stdnum.br.cpf.compact(number)

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

stdnum.br.cpf.format(number)

Reformat the number to the standard presentation format.

stdnum.br.cpf.is_valid(number)

Check if the number is a valid CPF.

stdnum.br.cpf.validate(number)

Check if the number is a valid CPF. This checks the length and whether the check digit is correct.