nric-utils
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

IC Cards including the ugly green one

NRIC Utils

Functions to validate and mask Singapore NRICs

MIT npm GitHub Workflow Status npm bundle size npm bundle size

Features

  • [x] Validate NRICs
  • [x] Mask NRICs (SXXXXXXXA => SXXXA)
  • [x] Validate masked NRICs
  • [ ] Yup integration
    • [ ] Yup method for validating NRICs
    • [ ] Yup method for validating masked NRICs
  • [ ] Generate NRICs
  • [ ] Tests
    • [x] Tests for validating NRICs
    • [x] Tests for masking NRICs
    • [x] Tests for validating masked NRICs
    • [ ] Tests for generating NRICs

Docs

Installation

npm install nric-utils

Usage

const { maskNric, validateNric } = require('nric-utils');
// Or
import { maskNric, validateNric } from 'nric-utils';

const nric = 'S0000002G';

validateNric(nric); 
// => true

maskNric('S0000002G'); 
// => 002G

/* 
Pass in true to maskNric to also include the first letter:
*/
maskNric('S0000002G', true); 
// => S002G

Build setup

Clone or fork the repository, then run

npm install

# to runs tests
npm run test -s

# format with prettier
npm run format

# build (convert to JavaScript)
npm run build

Format and ensure tests pass before pushing.

License

MIT

Blue IC Card

Readme

Keywords

Package Sidebar

Install

npm i nric-utils

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

9.1 kB

Total Files

14

Last publish

Collaborators

  • ninest