0.1.1 • Published 5 years ago

nric-utils v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Features

  • Validate NRICs
  • Mask NRICs (SXXXXXXXA => SXXXA)
  • Validate masked NRICs
  • Yup integration
    • Yup method for validating NRICs
    • Yup method for validating masked NRICs
  • Generate NRICs
  • Tests
    • Tests for validating NRICs
    • Tests for masking NRICs
    • 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