social-insurance-number
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();
sin = new SocialInsuranceNumber("123456789");
sin.isValid();
Use .normalizedValue()
to get the normalized SIN value (all non-digits removed).
var sin = new SocialInsuranceNumber("130-692-544");
sin.normalizedValue();
sin = new SocialInsuranceNumber(" 130692544 ");
sin.normalizedValue();
Use .isTemporary()
to determine if the SIN is associated with a temporary resident.
var sin = new SocialInsuranceNumber("918640897");
sin.isTemporary();
sin = new SocialInsuranceNumber("130692544");
sin.isTemporary();
Use .isBusinessNumber()
to determine if the SIN is a Business Number.
var sin = new SocialInsuranceNumber("817640897");
sin.isBusinessNumber();
sin = new SocialInsuranceNumber("130692544");
sin.isBusinessNumber();
Use .provinces()
to get the Canadian provinces associated with the SIN.
var sin = new SocialInsuranceNumber("130692544");
sin.provinces();
var tempSin = new SocialInsuranceNumber("918640897");
tempSin.provinces();
Generating
Use the .generate([options ])
class method to generate a valid random SIN number.
SocialInsuranceNumber.generate()
SocialInsuranceNumber.generate({province: "ON"});
SocialInsuranceNumber.generate({startsWith: "8"});
SocialInsuranceNumber.generate({startsWith: "12345"});
SocialInsuranceNumber.generate({doesNotStartWith: "1"});
SocialInsuranceNumber.generate({doesNotStartWith: ["1", "5"]});