stdnum.bg.pnf

PNF (ЛНЧ, Личен номер на чужденец, Bulgarian number of a foreigner).

The personal number of a foreigner is a 10-digit number where the last digit is the result of a weighted checksum.

>>> validate('7111 042 925')
'7111042925'
>>> validate('7111042922')  # invalid check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('71110A2922')  # invalid digit
Traceback (most recent call last):
    ...
InvalidFormat: ...
stdnum.bg.pnf.calc_check_digit(number)

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

stdnum.bg.pnf.compact(number)

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

stdnum.bg.pnf.is_valid(number)

Check if the number is a valid national identification number.

stdnum.bg.pnf.validate(number)

Check if the number is a valid national identification number. This checks the length, formatting, embedded date and check digit.