Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

social-insurance-number

Package Overview
Dependencies
Maintainers
5
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

social-insurance-number

Canadian SIN (Social Insurance Number) parser and generator

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

social-insurance-number CircleCI Code Climate

social-insurance-number is a Canadian SIN (Social Insurance Number) parser and generator for the browser and Node.js.

Parsing

Use the .isValid() to determine SIN validity.

var sin = new SocialInsuranceNumber("130692544");
sin.isValid();
// Returns: true

sin = new SocialInsuranceNumber("123456789");
sin.isValid();
// Returns: false

Use .normalizedValue() to get the normalized SIN value (all non-digits removed).

var sin = new SocialInsuranceNumber("130-692-544");
sin.normalizedValue();
// Returns "130692544"

sin = new SocialInsuranceNumber("  130692544 ");
sin.normalizedValue();
// Returns "130692544"

Use .isTemporary() to determine if the SIN is associated with a temporary resident.

var sin = new SocialInsuranceNumber("918640897");
sin.isTemporary();
// Returns: true

sin = new SocialInsuranceNumber("130692544");
sin.isTemporary();
// Returns: false

Use .isBusinessNumber() to determine if the SIN is a Business Number.

var sin = new SocialInsuranceNumber("817640897");
sin.isBusinessNumber();
// Returns: true

sin = new SocialInsuranceNumber("130692544");
sin.isBusinessNumber();
// Returns: false

Use .provinces() to get the Canadian provinces associated with the SIN.

var sin = new SocialInsuranceNumber("130692544");
sin.provinces();
// Returns: ['NB', 'NF', 'NS', 'PE']

var tempSin = new SocialInsuranceNumber("918640897");
tempSin.provinces();
// Returns: []

Generating

Use the .generate([options ]) class method to generate a valid random SIN number.

SocialInsuranceNumber.generate()
// Returns a random SIN, e.g. "130692544"

SocialInsuranceNumber.generate({province: "ON"});
// Returns a random SIN associated with Ontario, e.g. "464679711"

SocialInsuranceNumber.generate({startsWith: "8"});
// Returns a random SIN starting with 8, e.g. "851157206"

SocialInsuranceNumber.generate({startsWith: "12345"});
// Returns a random SIN starting with 12345, e.g. "123453235"

SocialInsuranceNumber.generate({doesNotStartWith: "1"});
// Returns a random SIN not starting with 1, e.g. "223453235"

SocialInsuranceNumber.generate({doesNotStartWith: ["1", "5"]});
// Returns a random SIN not starting with 1 or 5, e.g. "323453235"

FAQs

Package last updated on 27 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc