A simple TypeScript utility library to validate Singapore NRIC or FIN.
- Validates NRIC and FIN numbers, or both (including M series)
- Strongly typed
- Tested with Vitest
npm install identification-validator
import { Validator } from 'identification-validator'; // import the library
// validation of NRIC
console.log(Validator.isValidNRIC("S1234567D")) // will return true
// validation of FIN
console.log(Validator.isValidFIN("F1234567N")) // will return true
// validation of FIN / NRIC
console.log(Validator.isValidId("F1234567N")) // will return true
import { Validator } from 'identification-validator'; // import the library
// generate a random NRIC
console.log(Validator.generateNRIC()); // give a random NRIC, with a random starting valid series
// generate a random FIN
console.log(Validator.generateFIN()) // give a random FIN, with a random starting valid series
Name | Arguments | Example | Remarks |
---|---|---|---|
isValidNRIC | string |
Validator.isValidNRIC("S1234567D") |
Checks whether the given string is a valid NRIC and return a boolean response |
isValidFIN | string |
Validator.isValidFIN("F1234567N") |
Checks whether the given string is a valid NRIC and return a boolean response |
isValidId | string |
Validator.isValidId("F1234567N") |
Checks whether the given string is a valid NRIC/ FIN and return a boolean response |
generateNRIC | - | Validator.generateNRIC() |
Generates a random NRIC and returns as a string |
generateFIN | - | Validator.generateFIN() |
Generates a random FIN and returns as a string |