Socket
Socket
Sign inDemoInstall

@anyfin/ssntools

Package Overview
Dependencies
0
Maintainers
6
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @anyfin/ssntools

A ssn parsing/validation/formatting library for all countries supported by anyfin


Version published
Weekly downloads
6
increased by500%
Maintainers
6
Install size
20.5 kB
Created
Weekly downloads
 

Readme

Source

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

FAQs

Last updated on 28 Jan 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc