Utilities for validating various formats of Indian system codes like Mobile, PAN, AADHAAR, GST and more!
npm install format-utils --saveconst { Validator } = require('format-utils');OR
import { Validator } from 'format-utils';A mobile is a 10 digit numerical code starting with either 6, 7, 8, 9.
let isValid = Validator.mobile('9876543210');
// isValid = true
isValid = Validator.mobile('5678943210');
// isValid = falseA pincode is a 6 digit numeric code used by Indian Post.
- The first character is a number from 1to9.
- The second to sixth characters are numberical sequence from 00000to99999.
let isValid = Validator.pincode('400001');
// isValid = true
isValid = Validator.pincode('0123456');
// isValid = falseA PAN is a 10 digit alphanumeric code issued by Income Tax Department of India.
- The first three characters are alphabetic series running from AAAtoZZZ.
- The fourth character represents the status of the PAN holder.
- Pstands for Individual
- Cstands for Company
- Hstands for Hindu Undivided Family (HUF)
- Astands for Association of Persons (AOP)
- Bstands for Body of Individuals (BOI)
- Gstands for Government Agency
- Jstands for Artificial Juridical Person
- Lstands for Local Authority
- Fstands for Firm/ Limited Liability Partnership
- Tstands for Trust
 
- The fifth character represents the first character of the PAN holder's last name/surname in case of an individual. In case of non-individual PAN holders fifth character represents the first character of PAN holder's name.
- The sixth to ninth characters are sequential numbers running from 0001to9999.
- The tenth character is an alphabetic check digit.
Visit this to know more about PAN.
let isValid = Validator.pan('ALWPG5809L');
// isValid = true
isValid = Validator.pan('ABAB12345Y');
// isValid = falseA TAN is a 10 digit alphanumeric code.
- The first four characters are alphabetic series running from AAAAtoZZZZ.
- The fifth to ninth characters are sequential numbers running from 00001to99999.
- The tenth character is an alphabetic character.
let isValid = Validator.tan('RAJA99999B');
// isValid = true
isValid = Validator.tan('RAJA999991');
// isValid = falseA CIN is a 21-digit alphanumeric code assigned by the Registrar of Companies (RoC) to every company registered in India.
- The first character is LorU(Listing status).
- The second to sixth characters are sequential numbers running from 00001to99999(Industry code).
- The seventh and eighth characters consist of two alphabetic characters (State code).
- The ninth to twelfth characters are numeric, representing year of incorporation.
- The thirteenth to fifteenth characters are alphabetic, representing the type of company.
- The sixteenth to twenty-first characters are sequential numbers running from 00001to99999(Registration number).
let isValid = Validator.cin('L12345MH2000PLC123456');
// isValid = true
isValid = Validator.cin('U12345BR2020PTC12A456');
// isValid = falseA UAN is a 12 digit numberic code that is issued to member of the Employees’ Provident Fund Organisation (EPFO).
let isValid = Validator.uan('987654321098');
// isValid = true
isValid = Validator.uan('A98765432109');
// isValid = falseA IFSC is a 11 digit alphanumberic code that is issued to member of the Employees’ Provident Fund Organisation (EPFO).
- The first four characters are alphabets that denote the bank name.
- The fifth character is numerical zero (0).
- The sixth to eleventh characters are numerical code that denote the branch name.
let isValid = Validator.ifsc('SBIN0011569');
// isValid = true
isValid = Validator.ifsc('BK1D0006046');
// isValid = falseA ESIC code is a 17 digit numerical code that is issued by Employee State Insurance Corporation.
let isValid = Validator.esic('12345678901234567');
// isValid = true
isValid = Validator.esic('1234567890123456');
// isValid = falseA IMEI is a 15 digit numeric code to identify mobile phones, as well as some satellite phones. The last digit of IMEI is a Luhn check digit.
let isValid = Validator.imei('490154203237518');
// isValid = true
isValid = Validator.imei('490154203237519');
// isValid = falseAadhaar is a 12 digit numberic code that can be obtained by residents or passport holders of India, based on their biometric and demographic data.
- The first character is a number between 2and9.
- The second to eleventh characters are random numbers.
- The twelfth character is a Verhoeff check digit.
let isValid = Validator.aadhaar('234567890124');
// isValid = true
isValid = Validator.aadhaar('187654321096');
// isValid = falseAadhaar VID is a 16 digit numberic code that can be used instead of Aadhaar number at the time of authentication to avoid sharing of Aadhaar number. The last digit is a Verhoeff check digit.
let isValid = Validator.aadhaarVID('9876543210987659');
// isValid = true
isValid = Validator.aadhaarVID('6234897234982734');
// isValid = falseA GISTIN is a 15 digit alphanumeric code assigned to a business or person registered under the GST Act.
- The first two characters are numerical series from 01to37denoting state code.
- The third to twelfth characters are PAN number of the GST registered entity.
- The thirteenth character is a alphabet assigned based on the number of registration within a state.
- The fourteenth character is Zby default.
- The fifteenth character is a check codeand can be an alphabet or a number.
let isValid = Validator.gst('22ALJPT5243L1ZS');
// isValid = true
isValid = Validator.gst('22ALJPT5243L1ZB');
// isValid = falseA vehicle number plate is an alphanumeric code assigned to a vehicle registered in India.
The current format of the registration index consists of 4 parts.
- The first two characters are alphanumeric code of the State / Union Territory where the vehicle is registered.
- The third & fourth characters the sequential number of a district.
- The third part consists of one, two or three letters or no letters at all.
- The fourth part is a number from 1 to 9999, unique to each plate.
let isValid = Validator.vehicleRegistration('DL4CAF4943');
// isValid = true
isValid = Validator.vehicleRegistration('DL4CAF494G');
// isValid = falseA VPA / UPI (Unified Payment Interface) ID is a unique id generated for use of UPI in India.
- VPA consists of alphabets, numbers, hyphen (-), underscore (_) and dot (.) as part of identification.
- The identification part is followed by @sign.
- The last part is the handle of the issuer bank or PSP (Payment Service Provider).
- The maximum length of VPA is 50 characters.
| Option | Type | Default | Description | 
|---|---|---|---|
| maxLength | number | 50 | Maximum length of the VPA address including @sign & the handle. | 
| handles | boolean | string[] | false | Whether to do additional check of verifying the handle. When it is truethe handle part is checked against default handles listed in vpa-handles.json.When it is string[]the handle part is checked against merged list of default handles listed in vpa-handles.json and the ones given as input. | 
let isValid = Validator.vpa('amazing-uid@upi');
// isValid = true
isValid = Validator.vpa('with@at@upi');
// isValid = false