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.

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

Calculate the check digit for personal codes. The number passed should not have the check digit included.

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.is_valid(number)

Checks to see if the number provided is a valid VAT number. This checks the length, formatting and check digit.

stdnum.ro.cnp.validate(number)

Checks to see if the number provided is a valid VAT number. This checks the length, formatting and check digit.

Previous topic

stdnum.ro.cf

Next topic

stdnum.se.orgnr