stdnum.ro.cnp

CNP (Cod Numeric Personal, Romanian Numerical Personal Code).

The CNP is a 13 digit number that includes information on the person’s gender, birth date and country zone.

More information:

>>> validate('1630615123457')
'1630615123457'
>>> get_county('1630615123457')
'Cluj'
>>> validate('0800101221142')  # invalid first digit
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> validate('1632215123457')  # invalid date
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> validate('1630615993454')  # invalid county
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> validate('1630615123458')  # invalid check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
stdnum.ro.cnp.calc_check_digit(number)

Calculate the check digit for personal codes.

stdnum.ro.cnp.compact(number)

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

stdnum.ro.cnp.get_birth_date(number)

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

stdnum.ro.cnp.get_county(number)

Get the county name from the number

stdnum.ro.cnp.is_valid(number)

Check if the number is a valid VAT number.

stdnum.ro.cnp.validate(number)

Check if the number is a valid VAT number. This checks the length, formatting and check digit.