1.2.2 • Published 3 years ago

@anyfin/ssntools v1.2.2

Weekly downloads
312
License
MIT
Repository
-
Last release
3 years ago

🆔 Anyfin SSN Tools

A social security number parsing/validation/formatting library for all countries supported by anyfin.

Countries supported currently:

  • Sweden : SE
  • Finland : FI

Getting started

  1. git clone this repo.
  2. yarn install installs dependencies
  3. yarn test for test mode.
  4. yarn build for building the library.

Examples

const { validate, mask } = require("@anyfin/ssntools");

expect(validate("199404011232", "SE")).toBe(true);

expect(validate("199404011233", "SE")).toBe(false);

expect(mask("199404011233", "SE")).toBe("199404****33");

expect(format("199404011233", "SE")).toBe("940401-1233");

//-----------

expect(validate("040394-6751", "FI")).toBe(true);

expect(validate("040394-6750", "FI")).toBe(false);

expect(mask("040394-6750", "FI")).toBe("040394-***0");

expect(format("040394-6750", "FI")).toBe("040394-6750");

For more details look at the test cases here: index.test.js

Details on formats and specs of National identifiers of Finland and Sweden can be found here: https://en.wikipedia.org/wiki/National_identification_number

Running Locally

Using yarn test you can trigger the jest test cases. Additionally you can use yarn link to run a local version of this package inside another repo to test breaking changes.

Deploy/Publish

In order to deploy new versions, simply bump the version in package.json and create a new github release.

Github action should automagically deploy it to npm. ✨

1.2.2

3 years ago

1.2.1

4 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago