stdnum.mx.curp

CURP (Clave Única de Registro de Población, Mexican personal ID).

The Clave Única de Registro de Población (Population Registry Code) is unique identifier for both citizens and residents of Mexico. The is an 18-character alphanumeric that contains certain letters from the person’s name, their gender and birth date and a check digit.

More information:

>>> validate('BOXW310820HNERXN09')
'BOXW310820HNERXN09'
>>> validate('BOXW310820HNERXN08')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> get_birth_date('BOXW310820HNERXN09')
datetime.date(1931, 8, 20)
>>> get_gender('BOXW310820HNERXN09')
'M'
stdnum.mx.curp.calc_check_digit(number)

Calculate the check digit.

stdnum.mx.curp.compact(number)

Convert the number to the minimal representation. This strips surrounding whitespace and separation dash.

stdnum.mx.curp.get_birth_date(number)

Split the date parts from the number and return the birth date.

stdnum.mx.curp.get_gender(number)

Get the gender (M/F) from the person’s CURP.

stdnum.mx.curp.is_valid(number, validate_check_digits=False)

Check if the number provided is a valid CURP.

stdnum.mx.curp.validate(number, validate_check_digits=False)

Check if the number is a valid CURP.