stdnum.us.itin

ITIN (U.S. Individual Taxpayer Identification Number).

The Individual Taxpayer Identification Number is issued by the United States IRS to individuals who are required to have a taxpayer identification number but who are not eligible to obtain a Social Security Number.

It is a nine-digit number that begins with the number 9 and the fourth and fifth digit are expected to be in a certain range.

>>> validate('912-90-3456')
'912903456'
>>> validate('9129-03456')  # dash in the wrong place
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> validate('123-45-6789')  # wrong start digit
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> validate('912-93-4567')  # wrong group
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> compact('1234-56-789')
'123456789'
>>> format('111223333')
'111-22-3333'
>>> format('123')  # unknown formatting is left alone
'123'
stdnum.us.itin.compact(number)

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

stdnum.us.itin.format(number)

Reformat the number to the standard presentation format.

stdnum.us.itin.is_valid(number)

Check if the number is a valid ITIN.

stdnum.us.itin.validate(number)

Check if the number is a valid ITIN. This checks the length, groups and formatting if it is present.