stdnum.bg.egn¶
EGN (ЕГН, Единен граждански номер, Bulgarian personal identity codes).
It is a 10-digit number of which the first 6 digits denote the person’s birth date, the next three digits represent a birth order number from which the person’s gender can be determined and the last digit is a check digit.
>>> compact('752316 926 3')
'7523169263'
>>> validate('8032056031')
'8032056031'
>>> get_birth_date('7542011030')
datetime.date(2075, 2, 1)
>>> validate('7552A10004') # invalid digit
Traceback (most recent call last):
...
InvalidFormat: ...
>>> validate('8019010008') # invalid date
Traceback (most recent call last):
...
InvalidComponent: ...
- stdnum.bg.egn.calc_check_digit(number)¶
Calculate the check digit. The number passed should not have the check digit included.
- stdnum.bg.egn.compact(number)¶
Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.
- stdnum.bg.egn.get_birth_date(number)¶
Split the date parts from the number and return the birth date.
- stdnum.bg.egn.is_valid(number)¶
Check if the number is a valid national identification number.
- stdnum.bg.egn.validate(number)¶
Check if the number is a valid national identification number. This checks the length, formatting, embedded date and check digit.