Gathering detailed insights and metrics for @innostes/validators
Gathering detailed insights and metrics for @innostes/validators
Gathering detailed insights and metrics for @innostes/validators
Gathering detailed insights and metrics for @innostes/validators
npm install @innostes/validators
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
3 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Mar 07, 2025
Latest Version
1.0.2
Package Id
@innostes/validators@1.0.2
Unpacked Size
25.23 kB
Size
5.73 kB
File Count
6
NPM Version
10.8.2
Node Version
22.8.0
Published on
Mar 07, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
A comprehensive collection of utility functions to validate common Indian documents, data formats, and other general validations. This package provides regular expression-based validators for accurate and quick input validation in your JavaScript or TypeScript projects.
You can install the package from npm by running:
1npm install @innostes/validators
Once the package is installed, you can import and use the validators in your project.
1import { 2 validateEmail, 3 validateURL, 4 validateStrongPassword, 5 validateAlphaNumeric, 6 validateAlphaWithSpace, 7 validateNumeric, 8 validateAlphaNumericWithSpecialChars, 9 validateAlphaNumericWithSpace, 10 validateAlphabets, 11 validatePhoneNumber, 12 validateIndianMobileNumber, 13 validatePAN, 14 validateAadhar, 15 validatePINCode, 16 validateGSTIN, 17 validateIFSCCode, 18 validateVoterID 19} from '@innostes/validators'; 20 21// Example: Validating Email 22const email = 'user@example.com'; 23console.log(validateEmail(email)); // true 24 25// Example: Validating URL 26const url = 'https://example.com'; 27console.log(validateURL(url)); // true 28 29// Example: Validating Strong Password 30const password = 'P@ssw0rd123'; 31console.log(validateStrongPassword(password)); // true 32 33// Example: Validating Alphanumeric String 34const alphanumeric = 'Hello123'; 35console.log(validateAlphaNumeric(alphanumeric)); // true 36 37// Example: Validating Indian Mobile Number 38const mobileNumber = '9876543210'; 39console.log(validateIndianMobileNumber(mobileNumber)); // true 40 41// Example: Validating PAN 42const pan = 'ABCDE1234F'; 43console.log(validatePAN(pan)); // true 44 45// Example: Validating Aadhar 46const aadhar = '234567890123'; 47console.log(validateAadhar(aadhar)); // true 48 49// Example: Validating PIN Code 50const pinCode = '110001'; 51console.log(validatePINCode(pinCode)); // true 52 53// Example: Validating GSTIN 54const gstin = '27ABCDE1234F1Z5'; 55console.log(validateGSTIN(gstin)); // true 56 57// Example: Validating IFSC Code 58const ifscCode = 'SBIN0001234'; 59console.log(validateIFSCCode(ifscCode)); // true 60 61// Example: Validating Voter ID 62const voterID = 'ABC1234567X'; 63console.log(validateVoterID(voterID)); // true
validateEmail(email: string): boolean
Validates an email address to ensure it follows the standard email format.
email
(string): The email address to validate.boolean
: true
if the email is valid, false
otherwise.1validateEmail('user@example.com'); // true
validateURL(url: string): boolean
Validates a URL, supporting both http
and https
protocols.
url
(string): The URL to validate.boolean
: true
if the URL is valid, false
otherwise.1validateURL('https://example.com'); // true 2validateURL('ftp://example.com'); // false 3validateURL('http://example.com'); // true
validateStrongPassword(password: string): boolean
Validates a strong password, requiring at least 8 characters with one uppercase letter, one lowercase letter, one digit, and one special character.
password
(string): The password to validate.boolean
: true
if the password is strong, false
otherwise.1validateStrongPassword('P@ssw0rd123'); // true 2validateStrongPassword('password123'); // false 3validateStrongPassword('P@ssword'); // false 4validateStrongPassword('P@ssw0rd'); // true
validateAlphaNumeric(value: string): boolean
Validates if the string contains only alphanumeric characters (letters and numbers).
value
(string): The string to validate.boolean
: true
if the string is alphanumeric, false
otherwise.1validateAlphaNumeric('Hello123'); // true 2validateAlphaNumeric('Hello 123'); // false 3validateAlphaNumeric('12345'); // true 4validateAlphaNumeric('Hello!'); // false
validateAlphaWithSpace(value: string): boolean
Validates if the string contains only alphabetic characters and spaces.
value
(string): The string to validate.boolean
: true
if the string contains only alphabets and spaces, false
otherwise.1validateAlphaWithSpace('Hello World'); // true 2validateAlphaWithSpace('Hello123'); // false 3validateAlphaWithSpace('Hello World!'); // false 4validateAlphaWithSpace('Hello'); // true
validateNumeric(value: string): boolean
Validates if the string contains only numeric characters (digits).
value
(string): The string to validate.boolean
: true
if the string is numeric, false
otherwise.1validateNumeric('12345'); // true 2validateNumeric('123 45'); // false 3validateNumeric('abc123'); // false 4validateNumeric('987654'); // true
validateAlphaNumericWithSpecialChars(value: string): boolean
Validates if the string contains only alphanumeric characters and special characters like underscore, hyphen, and period.
value
(string): The string to validate.boolean
: true
if the string contains only alphanumeric characters and allowed special characters (_
, -
, .
), false
otherwise.1validateAlphaNumericWithSpecialChars('Hello_123'); // true 2validateAlphaNumericWithSpecialChars('Hello-123.World'); // true 3validateAlphaNumericWithSpecialChars('Hello@123'); // false 4validateAlphaNumericWithSpecialChars('Hello 123'); // false
validateAlphaNumericWithSpace(value: string): boolean
Validates if the string contains only alphanumeric characters and spaces.
value
(string): The string to validate.boolean
: true
if the string contains only alphanumeric characters and spaces, false
otherwise.1validateAlphaNumericWithSpace('Hello 123'); // true 2validateAlphaNumericWithSpace('Hello_123'); // false 3validateAlphaNumericWithSpace('12345'); // true 4validateAlphaNumericWithSpace('Hello World!'); // false
validateAlphabets(value: string): boolean
Validates if the string contains only alphabetic characters (no spaces, no digits, no special characters).
value
(string): The string to validate.boolean
: true
if the string contains only alphabetic characters, false
otherwise.1validateAlphabets('Hello'); // true 2validateAlphabets('Hello123'); // false 3validateAlphabets('Hello World'); // false 4validateAlphabets('Hello!'); // false
validatePhoneNumber(phone: string): boolean
Validates a phone number. It can include an optional international prefix, followed by numbers and possible spaces or hyphens.
phone
(string): The phone number to validate.boolean
: true
if the phone number is valid, false
otherwise.1validatePhoneNumber('+1 123-456-7890'); // true 2validatePhoneNumber('123-456-7890'); // true 3validatePhoneNumber('1234567890'); // true 4validatePhoneNumber('123-45-6789'); // true 5validatePhoneNumber('123 45 6789'); // true 6validatePhoneNumber('123 45-67890'); // false 7validatePhoneNumber('123abc4567'); // false 8
validateIndianMobileNumber(number: string): boolean
Validates an Indian mobile number. The number should begin with a digit between 7 and 9, followed by 9 digits.
number
(string): The mobile number to validate.boolean
: true
if the mobile number is valid, false
otherwise.1validateIndianMobileNumber('9876543210'); // true 2validateIndianMobileNumber('9123456789'); // true 3validateIndianMobileNumber('1234567890'); // false 4validateIndianMobileNumber('998877665'); // false 5validateIndianMobileNumber('7896541230'); // true 6validateIndianMobileNumber('123456789'); // false
validatePAN(pan: string): boolean
Validates an Indian Permanent Account Number (PAN). A PAN consists of 5 uppercase letters, 4 digits, and 1 uppercase letter at the end.
pan
(string): The PAN to validate.boolean
: true
if the PAN is valid, false
otherwise.1validatePAN('ABCDE1234F'); // true 2validatePAN('A1BCD2345E'); // false 3validatePAN('ABCDE12345'); // false 4validatePAN('ABCDE1234G'); // true 5validatePAN('abcde1234f'); /
validateAadhar(aadhar: string): boolean
Validates an Indian Aadhar number. Aadhar numbers consist of 12 digits, starting with a number between 2 and 9.
aadhar
(string): The Aadhar number to validate.boolean
: true
if the Aadhar number is valid, false
otherwise.1validateAadhar('123456789012'); // false 2validateAadhar('234567890123'); // true 3validateAadhar('987654321012'); // true 4validateAadhar('012345678901'); // false 5validateAadhar('1234ABCD5678'); // false
validatePINCode(pin: string): boolean
Validates an Indian PIN code. A valid PIN code consists of 6 digits, with the first digit between 1 and 9.
pin
(string): The PIN code to validate.boolean
: true
if the PIN code is valid, false
otherwise.1validatePINCode('110001'); // true 2validatePINCode('123456'); // true 3validatePINCode('000000'); // false 4validatePINCode('987654'); // true 5validatePINCode('12345'); // false 6validatePINCode('123AB6');
validateGSTIN(gstin: string): boolean
Validates an Indian GSTIN (Goods and Services Tax Identification Number). A valid GSTIN consists of 15 characters in a specific format:
The first 2 characters are digits (representing the state code).
The next 10 characters are alphanumeric (representing the PAN number).
The 13th character is a letter (for the tax payer type).
The 14th character is a letter or number (for the state code).
The 15th character is a check digit.
Parameters:
gstin
(string): The GSTIN to validate.Returns:
boolean
: true
if the GSTIN is valid, false
otherwise.Example:
1validateGSTIN('22ABCDE1234F1Z5'); // true 2validateGSTIN('29AABCU9603R1Z5'); // true 3validateGSTIN('27AAEPL1234F1Z9'); // true 4validateGST
validateIFSCCode(ifscCode: string): boolean
Validates an Indian IFSC (Indian Financial System Code) code. A valid IFSC code consists of 11 characters:
The first 4 characters are uppercase letters (representing the bank code).
The 5th character is always 0
(reserved for future use).
The last 6 characters are numeric (representing the branch code).
Parameters:
ifscCode
(string): The IFSC code to validate.Returns:
boolean
: true
if the IFSC code is valid, false
otherwise.Example:
1validateIFSCCode('HDFC0001234'); // true 2validateIFSCCode('SBI0005678'); // true 3validateIFSCCode('ICIC0001234'); // true
validateVoterID(voterID: string): boolean
Validates an Indian Voter ID. A valid Voter ID consists of 10 characters in the following format:
The first 3 characters are uppercase letters (representing the state code).
The next 7 characters are digits (representing the unique voter ID number).
The 10th character is an uppercase letter.
Parameters:
voterID
(string): The Voter ID to validate.Returns:
boolean
: true
if the Voter ID is valid, false
otherwise.Example:
1validateVoterID('ABC1234567X'); // true 2validateVoterID('XYZ9876543A'); // true 3validateVoterID('MNP1234567B'); // true 4validateVoterID('ABC1234A67X'); // false 5validateVoterID('A123456789'); // false 6validateVoterID('ABC12345678X'); // false
This project is licensed under the MIT License by Innostes Solutions.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For any inquiries or support, please contact us at:
No vulnerabilities found.
No security vulnerabilities found.