mm-nric
v0.5.0
Published
Myanmar nric list and validation methods for myanmar nationality identification. !!BETA!!
Downloads
21
Maintainers
Readme
Myanmar NRC
This package is to streamline development for myanmar nric input and verification.
Installation
Using npm:
npm install mm-nric
Using yarn:
yarn add mm-nric
Using pnpm:
pnpm add mm-nric
After installation you can use the package with either import
or requrie
approach.
Example
import { getStates } from 'mm-nric'
console.log(getStates())
// OR
const mmNric = require('mm-nric')
console.log(mmNric.getStates()
Functions
Generators
Get States
Returns an array of all states.
const states = getStates()
Get District
Returns an array of all districts.
const districts = getDistricts()
Get District by state
Returns an array of districts included in the specified state. Useful for controlling the dropdown values based on the state that the user chose.
NOTE: This function will return an empty array for invalid state code.
const districts = getDistrictsByState(1)
Validators
Validate State
Returns a boolean to check if the specified state code is valid.
NOTE: valid state codes are numbers ranging from 1 to 14
console.log(validateState(1)) // true
console.log(validateState(0)) // false
console.log(validateState(15)) // false
Validate Nric Type
Returns a boolean to check if the specified nric type is valid. Useful to validate raw user inputs
console.log(validateNricType('N')) // true
console.log(validateNricType('A')) // false
Validate Nric Format
Returns a boolean to check if the specified nric string is in valid format. Supports for both myanmar and english language.
console.log(validateNricFormat('12/PABADA(N)0XXXXX')) // en
console.log(validateNricFormat('၁၂/ပဘတ(နိုင်)၀xxxxx')) // mm
Validate Nric (WIP)
Returns a boolean to check if the specified nric string is valid. Supports for both myanmar and english language.
Currently only supports english NRIC
console.log(validateNric('12/PABADA(N)0XXXXX')) // true
Conversions
Convert To English
Convert the provided NRIC string from myanmar to english.
console.log(convertToEnglish('၁၂/ပဇတ(နိုင်)၀၀၀၀၀၀')) // 12/PAZATA(N)000000
Convert To Myanmar
Convert the provided NRIC string from english to myanmar.
console.log(convertToEnglish('12/PAZATA(N)000000')) // ၁၂/ပဇတ(နိုင်)၀၀၀၀၀၀
Data Types
State
interface State {
en: string; /* English State Name */
mm: string; /* Burmese State Suffix */
code: number; /* The State code */
}
District
interface District {
en: string; /* English District Suffix */
mm: string; /* Burmese District Suffix */
code: number; /* The State code */
fullEn: string; /* Full English District Name */
fullMm: string; /* Full Burmese District Name */
}
Nric Types
enum NricTypesEn {
N = 'N',
E = 'E',
P = 'P',
}
enum NricTypesMm {
N = 'နိုင်',
E = 'ဧည့်',
P = 'ပြု',
}