stdnum.us.ssn

SSN (U.S. Social Security Number).

The Social Security Number is used to identify individuals for taxation purposes.

>>> validate('536-90-4399')
'536904399'
>>> validate('1112-23333')  # dash in the wrong place
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> validate('666-00-0000')  # invalid area
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> validate('078-05-1120')  # blacklisted entry
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> compact('1234-56-789')
'123456789'
>>> format('111223333')
'111-22-3333'
stdnum.us.ssn.compact(number)

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

stdnum.us.ssn.format(number)

Reformat the passed number to the standard format.

stdnum.us.ssn.is_valid(number)

Checks to see if the number provided is a valid SSN. This checks the length, groups and formatting if it is present.

stdnum.us.ssn.validate(number)

Checks to see if the number provided is a valid SSN. This checks the length, groups and formatting if it is present.

Previous topic

stdnum.us.ptin

Next topic

stdnum.us.tin