stdnum.es.nie

NIE (Número de Identificación de Extranjeros, Spanish foreigner number).

The NIE is an identification number for foreigners. It is a 9 digit number where the first digit is either X, Y or Z and last digit is a checksum letter.

>>> validate('x-2482300w')
'X2482300W'
>>> validate('x-2482300a')  # invalid check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('X2482300')  # digit missing
Traceback (most recent call last):
    ...
InvalidLength: ...
Traceback (most recent call last):
    ...
InvalidLength: ...
stdnum.es.nie.compact(number)

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

stdnum.es.nie.is_valid(number)

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

Previous topic

stdnum.es.dni

Next topic

stdnum.es.nif