stdnum.my.nric

NRIC No. (Malaysian National Registration Identity Card Number).

The NRIC No. is the unique identifier for issued to Malaysian citizens and permanent residents.

The number consist of 12 digits in three sections. The first 6 digits represent the birth date, followed by two digits represeting the birth place and finally four digits. The gender of a person can be derived from the last digit: odd numbers for males and even numbers for females.

>>> validate('770305-02-1234')
'770305021234'
>>> validate('771305-02-1234')  # invalid date
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> validate('770305-17-1234')  # unknown birth place code
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> format('770305021234')
'770305-02-1234'
stdnum.my.nric.compact(number)

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

stdnum.my.nric.format(number)

Reformat the number to the standard presentation format.

stdnum.my.nric.get_birth_date(number)

Split the date parts from the number and return the birth date. Note that in some cases it may return the registration date instead of the birth date and it may be a century off.

stdnum.my.nric.get_birth_place(number)

Use the number to look up the place of birth of the person. This can either be a state or federal territory within Malaysia or a country outside of Malaysia.

stdnum.my.nric.is_valid(number)

Check if the number is a valid NRIC number.

stdnum.my.nric.validate(number)

Check if the number is a valid NRIC number. This checks the length, formatting and birth date and place.