A utility to validate social security number of different countries.

Usage no npm install needed!

<script type="module">
  import adiaTechnologyInternationalSsnValidator from 'https://cdn.skypack.dev/@adia-technology/international-ssn-validator';


International SSN Validator

This utility checks validity of Social Security Numbers. Currently supported countries are USA and Switzerland.

Getting started


npm install @adia-technology/international-ssn-validator --save


import { validateSsn, ValidationResult } from '@adia-technology/international-ssn-validator';

let validationResult = validateSsn('756.1111.2222.00', 'ch');
let isValid = validationResult === ValidationResult.Valid;


This library exposes a single function, validateSsn, that accepts two parameters:

  • ssn : string - SSN to validate.
  • countryCode : string - country for which to check the SSN against. Currently supported are us and ch.

It returns a ValidationResult, which essentially is a string enum being set to one of the values: 'VALID', 'INVALID_FORMAT' or 'INVALID_CHECKSUM'.


This library uses the following other libraries: