stdnum.ca.sin

SIN (Canadian Social Insurance Number).

The Social Insurance Number (SIN) is a 9-digit identifier issued to individuals for various government programs. SINs that begin with a 9 are issued to temporary workers who are neither Canadian citizens nor permanent residents.

More information:

>>> validate('123-456-782')
'123456782'
>>> validate('999-999-999')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('12345678Z')
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> validate('823456785')
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> format('123456782')
'123-456-782'
stdnum.ca.sin.compact(number)

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

stdnum.ca.sin.format(number)

Reformat the number to the standard presentation format.

stdnum.ca.sin.is_valid(number)

Check if the number is a valid SIN.

stdnum.ca.sin.validate(number)

Check if the number is a valid SIN. This checks the length, formatting and check digit.