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:
- https://www.canada.ca/en/employment-social-development/services/sin.html
- https://en.wikipedia.org/wiki/Social_Insurance_Number
>>> validate('123-456-782')
'123456782'
>>> validate('999-999-999')
Traceback (most recent call last):
...
InvalidChecksum: ...
>>> validate('12345678Z')
Traceback (most recent call last):
...
InvalidFormat: ...
>>> 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.