npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@inubeapislive/validations

v1.1.0

Published

Reusable validation helpers for APIsLive UI

Readme

@inubeapislive/validations

A comprehensive, zero-dependency validation utility library for the iNube platform. Provides 60+ validation functions covering required checks, email, mobile, PAN, length constraints, alphabetic/numeric patterns, date formats, address patterns, identity documents (GST, passport, CKYC, IFSC, PIN), and string sanitization.

All validators follow a consistent return pattern and integrate seamlessly with @inubeapislive/render-control's validation pipeline — validators are resolved by name at runtime from this package.

Installation

npm install @inubeapislive/validations

No peer dependencies. Works in browser and Node.js (ESM and CJS).


Return Value Convention

All validation functions follow one of these return patterns:

| Pattern | Returns on Pass | Returns on Fail | Returns on Empty | |---------|----------------|-----------------|------------------| | Boolean | true | false | false | | Strict | true | Error message string | false | | Guard | true | Error message string | — |

The "Strict" pattern is used by validators designed for form fields — they return true on success, an error message string on failure, and false when the value is empty (allowing separate required-field handling).


Integration with @inubeapislive/render-control

When using the render-control schema engine, validators are referenced by name in the JSON schema:

{
  "path": "email",
  "type": "text",
  "label": "Email",
  "blurValidators": [
    { "name": "IsRequired" },
    { "name": "isEmail" }
  ]
}

The render-control pipeline automatically imports and calls the matching function from this package. No manual wiring needed.

Custom Validators

You can also pass custom validators alongside these built-in ones:

<RenderEngine
  schema={schema}
  customValidators={{
    isUniquePolicyNo: async (value) => {
      const exists = await api.checkPolicy(value);
      return exists ? 'Policy number already in use' : true;
    },
  }}
/>

Custom validators take priority over built-in ones if names collide.


API Reference

Required Validations

isRequired(value: unknown): boolean

Strict check for non-empty values. Returns false for null, undefined, empty strings "", and whitespace-only strings.

import { isRequired } from '@inubeapislive/validations';

isRequired('hello');    // true
isRequired('');         // false
isRequired(null);       // false
isRequired(undefined);  // false
isRequired(0);          // true (numbers are truthy)
isRequired([]);         // true (arrays are truthy, even empty)

Email Validations

isEmail(email: string): true | string | false

Standard email format validation using regex. Returns true if valid, "Not a valid Email" if malformed, false if empty.

import { isEmail } from '@inubeapislive/validations';

isEmail('[email protected]');   // true
isEmail('invalid-email');       // "Not a valid Email"
isEmail('');                    // false

isValidEmailAddress(email: string): true | string | false

Enhanced email validation with length checks (max 40 chars) and structural validation (local part ≥ 3, domain ≥ 3).

isValidEmailAddress('[email protected]');     // "Local part or domain part of the email is too short"
isValidEmailAddress('[email protected]'); // true

validateMailID(email: string): true | string

Strict enterprise email validation with detailed error descriptions. Checks username format, domain structure, special characters, consecutive dots, valid TLDs, and length (max 60 chars).

validateMailID('[email protected]');        // true
validateMailID('user@@gmail.com');       // "Invalid Email Id"
validateMailID('[email protected]');                 // "Invalid Email Id"

isVerifiedEmailDomain(email: string, allowedDomains?: string[]): true | string | false

Validates email AND checks domain against a whitelist. Default allowed: gmail.com, yahoo.com, hotmail.com, outlook.com, etc.

isVerifiedEmailDomain('[email protected]');           // true
isVerifiedEmailDomain('[email protected]');          // "Not valid Email"
isVerifiedEmailDomain('[email protected]', ['company.in']); // true

Mobile Validations

isMobileNumber(number: string): true | string

Validates Indian mobile numbers. Exactly 10 digits, must start with 6, 7, 8, or 9.

import { isMobileNumber } from '@inubeapislive/validations';

isMobileNumber('9876543210');  // true
isMobileNumber('1234567890');  // "Not a valid Mobile Number" (starts with 1)
isMobileNumber('987');         // "Not a valid Mobile Number" (too short)

isMobileNumberNonZero(number: string): true | string

Same as isMobileNumber plus rejects numbers that are all zeros (e.g., 0000000000).


PAN Validation

isPan(pan: string): true | string

Validates Indian Permanent Account Number. Format: 5 uppercase letters + 4 digits + 1 uppercase letter (e.g., ABCDE1234F).

import { isPan } from '@inubeapislive/validations';

isPan('ABCDE1234F');  // true
isPan('abcde1234f');  // "Not a valid PAN" (lowercase)
isPan('12345ABCDE');  // "Not a valid PAN" (wrong structure)

Length Validations

isMinLength(value: string, min: number): boolean

Returns true if value.length >= min.

isMaxLength(value: string, max: number): boolean

Returns true if value.length <= max.

isExactLength(value: string, length: number): boolean

Returns true if value.length === length.

import { isMinLength, isMaxLength, isExactLength } from '@inubeapislive/validations';

isMinLength('hello', 3);     // true
isMinLength('hi', 3);        // false
isMaxLength('hello', 10);    // true
isExactLength('123456', 6);  // true

Usage in render-control schemas:

{
  "validators": [
    { "name": "isMinLength", "params": [2] },
    { "name": "isMaxLength", "params": [50] }
  ]
}

Alphabetic & String Validations

| Function | Allows | Example Valid | |----------|--------|--------------| | isAlpha(v) | Letters only (a-zA-Z) | "John" | | isAlphaSpace(v) | Letters + spaces | "John Doe" | | isAlphaSpaceDot(v) | Letters + spaces + dots | "Dr. Smith" | | isAlphaNum(v) | Letters + digits | "Room4A" | | isAlphaNumSpace(v) | Letters + digits + spaces | "Block 2A" | | isAlphaNumSpecial(v) | Alphanumeric + special chars | "user@123!" | | isAlphaNumThreeSpecial(v) | Alphanumeric + max 3 special chars | "name-1.0" | | isAlphaAndSpecialChar(v) | Letters + special chars | "hello-world!" | | isAlphaCommaAndQuote(v) | Letters + commas + quotes | "O'Brien, Jr." |

All return boolean.

import { isAlphaSpace, isAlphaNum } from '@inubeapislive/validations';

isAlphaSpace('John Doe');   // true
isAlphaSpace('John123');    // false
isAlphaNum('Room4A');       // true

Numeric Validations

| Function | Description | Example Valid | |----------|-------------|--------------| | isNumeric(v) | Digits only | "12345" | | isNumericNonZero(v) | Digits only, not all zeros | "100" | | isNumericDot(v) | Digits + one decimal dot | "12.5" | | isFloatingNumeric(v) | Valid floating point number | "3.14159" | | isFloat(v) | Valid float string | "0.5" | | isNumericPercentage(v) | Numeric percentage | "75" | | isNumericPercentageZeroToHundred(v) | 0–100 inclusive | "99" | | isNumericNonZeroAndHundred(v) | 1–100 inclusive | "50" | | isNumberDecimalFloat100(v) | Decimal up to 100 | "99.9" | | numBetween(v, min, max) | Number in range | numBetween(5, 1, 10)true | | isNumBetween(v, min, max) | String-parsed number in range | isNumBetween("5", 1, 10)true |

All return boolean.

import { isNumeric, numBetween } from '@inubeapislive/validations';

isNumeric('12345');         // true
isNumeric('12.5');          // false (has dot)
numBetween(25, 18, 65);    // true

Special Character & Mixed Validations

| Function | Description | |----------|-------------| | isSpecialChar(v) | Only special characters | | isNumericSpecial(v) | Digits + special characters | | isNumericSpecialNoSpace(v) | Digits + special chars, no spaces | | isFreetextNoSpace(v) | Any char except spaces | | isSentence(v) | Sentence structure (letters, spaces, punctuation) | | isAll(v) | Accepts everything (always true) |


Date Validations

dateValidation(dateStr: string): boolean

Validates standard date format (DD/MM/YYYY or DD-MM-YYYY).

dateValidation1(dateStr: string): boolean

Alternative date format validation (YYYY-MM-DD).

getDaysInMonth(month: number, year: number): number

Utility that returns the number of days in a given month/year (handles leap years).

import { getDaysInMonth } from '@inubeapislive/validations';

getDaysInMonth(2, 2024);  // 29 (leap year)
getDaysInMonth(2, 2023);  // 28
getDaysInMonth(12, 2025); // 31

Address Validations

addressRegex(address: string): boolean

Validates address format (alphanumeric + common address punctuation).

licAddressRegex(address: string): boolean

Validates address specifically for LIC (Life Insurance Corporation) formatting rules.

replaceAddressRegex(address: string): string

Sanitization utility — strips invalid characters from an address string, returning the cleaned version.


Identity & Document Validations

| Function | Format | Example Valid | |----------|--------|--------------| | isGstNo(gst) | 15-char GST format: 2 digits + PAN + 1 alphanumeric + Z + 1 check | "29ABCDE1234F1Z5" | | isPassport(passport) | Indian passport: 1 letter + 7 digits | "A1234567" | | isCKYC(ckyc) | 14-digit CKYC number | "12345678901234" | | isIFSCode(ifsc) | 11-char IFSC: 4 letters + 0 + 6 alphanumeric | "SBIN0001234" | | isPinCode(pincode) | 6-digit Indian PIN code (doesn't start with 0) | "560001" | | isPolicyNo(policyNo) | Alphanumeric policy number | "POL12345" | | isAge(age) | Valid age (1–150) | "35" |

All return boolean.

import { isGstNo, isIFSCode, isPinCode } from '@inubeapislive/validations';

isGstNo('29ABCDE1234F1Z5');   // true
isIFSCode('SBIN0001234');     // true
isPinCode('560001');          // true
isPinCode('060001');          // false (starts with 0)

Type Validations

isBoolean(value: unknown): boolean

Returns true if the value is a boolean (true or false).

isFunction(value: unknown): boolean

Returns true if the value is a function.


Sanitization Utilities

These functions transform strings rather than validate them:

removeAllSpecialChar(value: string): string

Strips all non-alphanumeric characters (keeps letters, digits, spaces).

removeAllSpecialChar('Hello! World #2024');  // "Hello World 2024"

removeAllSpecialCharWithoutComma(value: string): string

Same as above but preserves commas.

removeAllSpecialCharWithoutComma('Price: $1,500!');  // "Price 1,500"

addDecimalZeroes(value: string | number): string

Formats a number to include two decimal places.

addDecimalZeroes(42);      // "42.00"
addDecimalZeroes('5.1');   // "5.10"

Legacy Aliases

For backward compatibility with the APIsLive-UI codebase, all validators are also exported with their original capitalized names:

| Modern (camelCase) | Legacy (PascalCase) | |-------------------|---------------------| | isRequired | IsRequired | | isEmail | IsEmail | | isMobileNumber | IsMobileNumber | | isPan | IsPan | | isMinLength | LengthNotLessThen | | isMaxLength | LengthNotGreaterThen | | isExactLength | LengthEqualTo | | isAlpha | IsAlpha | | isAlphaSpace | IsAlphaSpace | | isNumeric | IsNumeric | | isNumericPercentage | IsNumaricPercentage | | isSpecialChar | IsSpecialChar | | isAll | All | | numBetween | NumBetween | | ... | (and more) |

Both names resolve to the same function. Use the modern camelCase names for new code.


Complete Export List

// Required
export { isRequired, IsRequired };

// Email
export { isEmail, IsEmail, isValidEmailAddress, validateMailID, isVerifiedEmailDomain };

// Mobile
export { isMobileNumber, IsMobileNumber, isMobileNumberNonZero, IsMobileNumberNonZero };

// PAN
export { isPan, IsPan };

// Length
export { isMinLength, isMaxLength, isExactLength };
export { LengthNotLessThen, LengthNotGreaterThen, LengthEqualTo }; // legacy

// Alphabetic
export { isAlpha, isAlphaSpace, isAlphaSpaceDot, isAlphaNum, isAlphaNumSpace,
         isAlphaNumSpecial, isAlphaNumThreeSpecial, isAlphaAndSpecialChar, isAlphaCommaAndQuote };

// Numeric
export { isNumeric, isNumericNonZero, isNumericDot, isFloatingNumeric, isFloat,
         isNumericPercentage, isNumericPercentageZeroToHundred, isNumericNonZeroAndHundred,
         isNumberDecimalFloat100, numBetween, isNumBetween };

// Special
export { isSpecialChar, isNumericSpecial, isNumericSpecialNoSpace, isFreetextNoSpace, isSentence, isAll };

// Date
export { dateValidation, dateValidation1, getDaysInMonth };

// Address
export { addressRegex, licAddressRegex, replaceAddressRegex };

// Identity
export { isGstNo, isPassport, isCKYC, isIFSCode, isPinCode, isPolicyNo, isAge };

// Type
export { isBoolean, isFunction };

// Sanitize
export { removeAllSpecialChar, removeAllSpecialCharWithoutComma, addDecimalZeroes };

Development

# Build
npm run build

# Clean
npm run clean

Package Info

  • Zero dependencies — pure TypeScript, no runtime deps
  • Tree-shakeable — import only what you need
  • Universal — works in browser and Node.js
  • TypeScript — full type definitions included
  • v2.1.0 — stable, used in production across iNube platform