Utilities for validating various formats of Indian system codes like Mobile, PAN, AADHAAR, GST and more!
npm install format-utils --save
const { 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 = false
A pincode is a 6 digit numeric code used by Indian Post.
- The first character is a number from
1
to9
. - The second to sixth characters are numberical sequence from
00000
to99999
.
let isValid = Validator.pincode('400001');
// isValid = true
isValid = Validator.pincode('0123456');
// isValid = false
A PAN is a 10 digit alphanumeric code issued by Income Tax Department of India.
- The first three characters are alphabetic series running from
AAA
toZZZ
. - The fourth character represents the status of the PAN holder.
P
stands for IndividualC
stands for CompanyH
stands for Hindu Undivided Family (HUF)A
stands for Association of Persons (AOP)B
stands for Body of Individuals (BOI)G
stands for Government AgencyJ
stands for Artificial Juridical PersonL
stands for Local AuthorityF
stands for Firm/ Limited Liability PartnershipT
stands 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
0001
to9999
. - 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 = false
A TAN is a 10 digit alphanumeric code.
- The first four characters are alphabetic series running from
AAAA
toZZZZ
. - The fifth to ninth characters are sequential numbers running from
00001
to99999
. - The tenth character is an alphabetic character.
let isValid = Validator.tan('RAJA99999B');
// isValid = true
isValid = Validator.tan('RAJA999991');
// isValid = false
A 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 = false
A 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 = false
A 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 = false
A 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 = false
Aadhaar 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
2
and9
. - 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 = false
Aadhaar 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 = false
A 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
01
to37
denoting 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
Z
by 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 = false
A 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 = false
A 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 true the 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