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

ajt-validator

v0.0.30

Published

Validation library for JavaScript and TypeScript

Readme

ajt-validator

A comprehensive, flexible validation library for JavaScript and TypeScript applications that provides robust data validation with minimal configuration.

Features

  • Type-safe validation - Built with TypeScript for strong typing
  • Modular architecture - Use only the validators you need
  • Extensible framework - Create custom validators by extending base classes
  • Rich validation results - Detailed error information and metadata
  • Zero dependencies - Lightweight and efficient
  • Framework agnostic - Works with any JS/TS project

Core Validators

Personal Information

  • NameValidator - Name validation with customizable format rules
  • DOBValidator - Date of birth validation with age calculations
  • AgeValidator - Age validation with minimum and maximum restrictions
  • GenderValidator - Gender validation with customizable options
  • PassportValidator - Passport number validation with authority checking

Contact Information

  • EmailValidator - Email address validation with domain restrictions
  • PhoneValidator - Phone number validation with international format support
  • AddressValidator - Address validation with customizable field requirements

Financial Information

  • BankAccountValidator - Bank account validation with routing number checksum verification
  • CreditCardValidator - Credit card validation with Luhn algorithm and card type detection

Authentication

  • PasswordValidator - Password strength and format validation with complexity requirements
  • UsernameValidator - Username format validation with blocked username detection
  • ApiKeyValidator - API key validation with format and prefix validation
  • TokenValidator - Authentication token validation including JWT support
  • TwoFactorValidator - Two-factor authentication code validation with expiration checking

Internet & Network

  • URLValidator - Advanced URL validation with protocol, domain, port, path, and query validation
  • IPAddressValidator - Validates IPv4 and IPv6 addresses with subnet restrictions
  • DomainValidator - Domain name validation with TLD checking and subdomain rules
  • URIValidator - General URI validation according to RFC 3986 standards

General Purpose

  • StringValidator - Text validation with length and format options
  • NumberValidator - Numeric validation with range checking
  • DateValidator - Date format and range validation

Installation

npm install ajt-validator

Usage

import { PersonalValidator, ContactValidator } from 'ajt-validator';

// Validate name
const nameValidator = new PersonalValidator.NameValidator({
  minLength: 2,
  maxLength: 50,
  allowSpecialChars: true
});

const nameResult = nameValidator.validate("O'Connor");
console.log(nameResult.success); // true

// Validate email
const emailValidator = new ContactValidator.EmailValidator({
  strictMode: true,
  blockedDomains: ['temporarymail.com']
});

const emailResult = emailValidator.validate('[email protected]');
console.log(emailResult.success); // true

// Validate address
const addressValidator = new ContactValidator.AddressValidator();
const addressResult = addressValidator.validate({
  street: '123 Main St',
  city: 'New York',
  state: 'NY',
  postalCode: '10001',
  country: 'USA'
});
console.log(addressResult.success); // true

Validation Results

All validators return consistent result objects with:

  • isValid - Boolean indicating validation success
  • value - The validated (and possibly transformed) value
  • errors - Array of detailed error objects with code and message
  • errorMessage - Human-readable error message if validation failed
  • Additional metadata specific to each validator type

Extending the Library

Create custom validators by extending the base classes:

import { BaseValidator } from 'ajt-validator';

class CustomValidator extends BaseValidator {
  validate(value) {
    // Custom validation logic
  }
}

Extensible Architecture

Each validator can be configured with options for your specific use case:

// Customize phone validation
const phoneValidator = new ContactValidator.PhoneValidator({
  requireCountryCode: true,
  allowedCountryCodes: ['1', '44', '61'], // US, UK, Australia
  minLength: 10,
  maxLength: 15,
  allowExtension: true
});

// Customize address validation
const addressValidator = new ContactValidator.AddressValidator({
  streetRequired: true,
  cityRequired: true,
  stateRequired: false, // Make state optional
  postalCodePattern: /^[0-9]{5}$/, // US 5-digit postal code
  maxStreetLength: 100
});

Creating Custom Validators

Create custom validators by extending the base classes:

import { BaseValidator } from 'ajt-validator';
import { ValidationResult } from 'ajt-validator/interfaces';

class CustomValidator extends BaseValidator<string> {
  validate(value: string): ValidationResult<string> {
    // Custom validation logic
    if (!value) {
      return this.createError('VALUE_REQUIRED', 'Value is required');
    }
    
    // Additional validation...
    
    return this.createSuccess(value);
  }
}

License

MIT