stdnum.cu.ni¶
NI (Número de identidad, Cuban identity card numbers).
Número de carnet de identidad is the Cuban national identifier that is assigned to residents. The number consists of 11 digits and include the date of birth of the person and gender.
More information:
>>> validate('91021027775')
'91021027775'
>>> validate('9102102777A')
Traceback (most recent call last):
...
InvalidFormat: ...
>>> get_birth_date('91021027775')
datetime.date(1991, 2, 10)
>>> get_gender('91021027775')
'F'
>>> get_birth_date('72062506561')
datetime.date(1972, 6, 25)
>>> get_gender('72062506561')
'M'
>>> get_birth_date('85020291531')
datetime.date(1885, 2, 2)
>>> get_birth_date('02023061531')
Traceback (most recent call last):
...
InvalidComponent: ...
- stdnum.cu.ni.compact(number)¶
Convert the number to the minimal representation. This strips surrounding whitespace and separation dash.
- stdnum.cu.ni.get_birth_date(number)¶
Split the date parts from the number and return the date of birth.
- stdnum.cu.ni.get_gender(number)¶
Get the gender (M/F) from the person’s NI.
- stdnum.cu.ni.is_valid(number)¶
Check if the number is a valid NI.
- stdnum.cu.ni.validate(number)¶
Check if the number is a valid NI. This checks the length, formatting and check digit.