Code Monkey home page Code Monkey logo

social-insurance-number's Introduction

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"

social-insurance-number's People

Contributors

6 avatar dependabot[bot] avatar natashad avatar arthur-conde avatar abejfehr avatar awaseem avatar dinahshi avatar osman avatar verkhoro avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.