stdnum.ch.ssn

Swiss social security number (“Sozialversicherungsnummer”).

Also known as “Neue AHV Nummer”. The Swiss Sozialversicherungsnummer is used to identify individuals for taxation and pension purposes.

The number is validated using EAN-13, though dashes are substituted for dots.

More information:

>>> validate('7569217076985')
'7569217076985'
>>> validate('756.9217.0769.85')
'7569217076985'
>>> validate('756.9217.0769.84')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('123.4567.8910.19')
Traceback (most recent call last):
    ...
InvalidComponent: ...
>>> format('7569217076985')
'756.9217.0769.85'
stdnum.ch.ssn.compact(number)

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

stdnum.ch.ssn.format(number)

Reformat the number to the standard presentation format.

stdnum.ch.ssn.is_valid(number)

Check if the number is a valid Swiss Sozialversicherungsnummer.

stdnum.ch.ssn.validate(number)

Check if the number is a valid Swiss Sozialversicherungsnummer.