Sri Lankan NIC validator which supports both old and new NIC formats. This package can be used to swap NIC, validate and get more info like, bday, gender etc..
- Validate NIC.
- Swap NIC. (Old to new or new to old)
- Extract NIC infromation. (Bday, Gender, etc..)
$ npm install lanka-nic-2019 --save
or
$ yarn add lanka-nic-2019
- First, require
const lankaNic = require('lanka-nic-2019');
or import
import lankaNic from 'lanka-nic-2019';
- Next, call the functions like:
lanakNic.infoNic('12345678912');
lanakNic.validateNic('12345678912');
lanakNic.swapNic('12345678912');
Method | Input | Output |
---|---|---|
validateNic | String : Old or new NIC number | Bool: true or false |
swapNic | String : Old or new NIC number | String : xxxxxxxxxv , Swap NIC old to new and vice versa. If entered Nic no. is incorrect will display 'incorrect format' error message. |
infoNic | String : Old or new NIC number | Object : |
{ |
||
isValidated: true, |
||
input: '123456789v', |
||
format: 'old', |
||
newFormat: '123456789000', |
||
oldFormat: '123456789v', |
||
nicLength: 10, |
||
gender: 'Male', |
||
character: 'v', |
||
birthday: '05/05/1903' |
||
} |
Any modification, correction welcome
- NodeJS(6+)
- EsLint supported editor.
Clone the repo and run yarn install
or npm install
. Make sure you have an editor with an eslint plugin active. Never start working without eslint.
Before pushing the code, please check for errors:
npm run test
We use SemVer for versioning. For the versions available, see the link to tags on this repository.
Always follow the AirBnb Style Guide.