stdnum.cr.cpf¶
CPF (Cédula de Persona Física, Costa Rica physical person ID number).
The Cédula de Persona Física (CPF), also known as Cédula de Identidad is an identifier of physical persons.
The number consists of 10 digits in the form 0P-TTTT-AAAA where P represents the province, TTTT represents the volume (tomo) padded with zeroes on the left, and AAAA represents the entry (asiento) also padded with zeroes on the left.
It seems to be usual for the leading zeroes in each of the three parts to be omitted.
More information:
https://www.procomer.com/downloads/quiero/guia_solicitud_vuce.pdf (page 11)
https://www.hacienda.go.cr/ATV/frmConsultaSituTributaria.aspx
>>> validate('3-0455-0175')
'0304550175'
>>> validate('30-1234-1234')
Traceback (most recent call last):
...
InvalidComponent: ...
>>> validate('12345678')
Traceback (most recent call last):
...
InvalidLength: ...
>>> format('701610395')
'07-0161-0395'
>>> format('1-613-584')
'01-0613-0584'
- stdnum.cr.cpf.compact(number)¶
Convert the number to the minimal representation.
This strips the number of any valid separators and removes surrounding whitespace. Also adds padding zeroes if necessary.
- stdnum.cr.cpf.format(number)¶
Reformat the number to the standard presentation format.
- stdnum.cr.cpf.is_valid(number)¶
Check if the number is a valid Costa Rica CPF number.
- stdnum.cr.cpf.validate(number)¶
Check if the number is a valid Costa Rica CPF number.
This checks the length and formatting.