@anyfin/ssntools
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

🆔 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.

Readme

Keywords

none

Package Sidebar

Install

npm i @anyfin/ssntools

Weekly Downloads

5

Version

1.2.2

License

MIT

Unpacked Size

21 kB

Total Files

23

Last publish

Collaborators

  • atul4anyfin
  • oskarengstrom
  • pepf
  • manueljtejada
  • divyanshutomar