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

input-validify

v3.1.3

Published

A lightweight javascript package to validate forms.

Readme

📦 Validify

A lightweight and powerful JavaScript validation library for usernames, passwords, emails, numbers, dates, URLs, phone numbers, and more — now with standardized error codes for cleaner error handling.


🚀 Installation

Install the package using npm:

npm install input-validify

📥 Import & Usage

import Validify from "input-validify";

const vld = new Validify();

🔤 Username Validation

validateText(text, special = false, min = 2, max = 20, allowedSymbols = [])

Validates a text input such as a username by restricting special characters and setting length limits.

Parameters:

  • text: string — The input text to validate.
  • special: boolean — Allow special characters (true) or not (false).
  • min: number — Minimum character length.
  • max: number — Maximum character length.
  • allowedSymbols: string[] — Custom allowed special characters (optional).

Example:

vld.validateText("User_123", true, 2, 10, ['_', '-', '@']);

🔐 Password Validation

validatePassword(password, min = 6, max = 20, complexity = {})

Validates passwords for minimum/maximum length and character complexity.

Parameters:

  • password: string — The password to validate.
  • min: number — Minimum character length.
  • max: number — Maximum character length.
  • complexity: object — Complexity rules:
    • requireUppercase: boolean
    • requireLowercase: boolean
    • requireNumber: boolean
    • requireSpecialChar: boolean

Example:

vld.validatePassword("StrongPass123!", 8, 20, {
  requireUppercase: true,
  requireLowercase: true,
  requireNumber: true,
  requireSpecialChar: true,
});

📧 Email Validation

validateEmail(email, regex?)

Validates email format using default or custom regular expression.

Parameters:

  • email: string — Email address to validate.
  • regex: RegExp — Optional custom regex.

Example:

vld.validateEmail("[email protected]");

// With custom regex
vld.validateEmail("[email protected]", /^[a-z0-9._%+-]+@gmail\.com$/i);

🔢 Number Validation

validateNumber(number, min = 4, max = 20)

Validates number or numeric string length.

Parameters:

  • number: number|string — The number to validate.
  • min: number — Minimum length.
  • max: number — Maximum length.

Example:

vld.validateNumber(123456, 4, 10);

📅 Date Validation

validateDate(date, format)

Validates date string based on format.

Supported Formats:

  • YYYY-MM-DD
  • DD/MM/YYYY
  • MM/DD/YYYY
  • YYYY/MM/DD
  • YYYY-MM-DD HH:mm:ss
  • DD/MM/YYYY HH:mm:ss
  • MM/DD/YYYY HH:mm:ss
  • YYYY/MM/DD HH:mm:ss
  • YYYY-MM-DDTHH:mm:ss
  • YYYY-MM-DDTHH:mm:ss.SSS

Parameters:

  • date: string — The date string to validate.
  • format: string — The expected format.

Example:

vld.validateDate("2025-03-15", "YYYY-MM-DD");
vld.validateDate("15/03/2025 10:30:00", "DD/MM/YYYY HH:mm:ss");

🌐 URL Validation

validateUrl(url)

Validates if the string is a valid URL.

Parameters:

  • url: string — The URL to validate.

Example:

vld.validateUrl("https://example.com");

🔎 Regex Validation

validateWithRegex(value, regex)

Custom validation using regular expressions.

Parameters:

  • value: string — The value to validate.
  • regex: RegExp — The regular expression.

Example:

vld.validateWithRegex("abc123", /^[a-z0-9]+$/i);

☎️ Phone Number Validation

validatePhone(phoneNumber)

Validates phone numbers in various formats.

Parameters:

  • phoneNumber: string — The phone number to validate.

Example:

vld.validatePhone("+1 (123) 456-7890");
vld.validatePhone("123-456-7890");

❗ Error Handling

All methods throw Error objects with error codes instead of plain text messages, so you can handle errors more programmatically:

Example:

try {
  vld.validateText("");
} catch (err) {
  console.log(err.message); // Example: "ERR_TEXT_EMPTY"
}

📄 License

MIT License


👨‍💻 Author

Ali Abdullah
GitHub