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

chain-schema-validator

v2025.9.8-2

Published

The perfect, feature-complete, chainable schema-based object validator for Node.js and browsers. Inspired by Joi.

Readme

Chain Schema Validator - The Perfect Schema Validation

The perfect, feature-complete, chainable schema-based object validator for Node.js and browsers. Inspired by Joi, rebuilt for ultimate power and flexibility with zero dependencies.

This is the definitive version of chain-schema-validator, designed to handle virtually any validation scenario you can imagine. It provides an expressive, fluent API to define schemas, transform data, and validate complex objects with ease.

Key Features

  • Massive & Comprehensive API: A huge library of validation methods for every data type.

  • Powerful Data Transformation: A dedicated pipeline for sanitizing, formatting, and setting defaults on your data before validation.

  • Advanced Conditional & Relational Logic: Define complex cross-field dependencies with rules like when, with, and switch-like logic using keys.

  • Deeply Nested Validation: Effortlessly validate complex nested objects and arrays.

  • Asynchronous Support: Built-in async capabilities for tasks like database lookups.

  • Zero Dependencies: Lightweight, fast, and secure.

Quick Start

Define individual field schemas, then compose them into an object schema.

const { schema, ref } = require('chain-schema-validator');

// 1. Define schemas for individual fields
const usernameSchema = schema.string()
    .trim()
    .lowercase()
    .token()
    .min(3)
    .required();

const passwordSchema = schema.string()
    .min(8)
    .required();

// 2. Compose into an object schema
const registrationSchema = schema.object({
    username: usernameSchema,
    email: schema.string().email().required(),
    password: passwordSchema,
    passwordConfirm: schema.string().valid(ref('password')).required().strip(),
    role: schema.string().default('user'),
    birthYear: schema.number().integer().min(1920).max(2015)
}, {
    abortEarly: false // Report all errors
});

// 3. Validate your data
const userData = {
    username: '  TEST_USER ',
    email: '[email protected]',
    password: 'password123',
    passwordConfirm: 'password123',
    birthYear: 1990
};

const { value, error } = registrationSchema.validate(userData);

if (error) {
    console.error('❌ Validation failed:', error.details);
} else {
    console.log('✅ Validation passed!');
    console.log('Sanitized Value:', value);
    /*
      Expected output:
      ✅ Validation passed!
      Sanitized Value: {
        username: 'test_user',
        email: '[email protected]',
        password: 'password123',
        role: 'user',
        birthYear: 1990
      }
    */
}

API Reference (Overview)

Schema Types

  • schema.string()

  • schema.number()

  • schema.boolean()

  • schema.array()

  • schema.object(schemaMap, options)

  • schema.date()

  • schema.any()

🟢 General / Utility Methods

  • State Modifiers: .required(), .optional(), .nullable(), .forbidden(), .strip()

  • Defaults & Values: .default(value), .valid(...values), .invalid(...values)

  • Custom Logic: .transform(fn), .custom(fn), .customAsync(fn)

  • Schema Composition: .concat(schema), .meta(info)

🟢 String-Specific Methods

  • Transformation: .trim(), .lowercase(), .uppercase()

  • Validation: .min(len), .max(len), .length(len), .pattern(regex), .creditCard(), .email(), .ip4(), .ip6(), .ip(), .uuid(), .hex(), .token(), .isoDate()

🟢 Number-Specific Methods

  • .min(val), .max(val), .greater(val), .less(val), .integer(), .positive(), .negative(), .port()

🟢 Array-Specific Methods

  • .min(len), .max(len), .length(len), .items(schema), .unique(), .has(schema), .single()

🟢 Object-Specific Methods

  • schema.object({ key: schema, ... }) is the primary method.

  • Options: { abortEarly: boolean, stripUnknown: boolean }

Contributing

This library is now feature-complete and in a stable state. Bug reports are welcome. Please see our Security Policy.

If you need just object validator, then you can see objectPropValidator.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

This packages codes was created by Mamedul Islam and open for contribute.

As a passionate web developer with experience in creating interactive and user-friendly web components. Currently available for freelance projects or full-time opportunities.

Helping businesses grow their online presence with custom web solutions. Specializing in WordPress, WooCommerce, NodeJS, and Shopify. Building modern, responsive, and high-performance scalable websites with custom made plugins, codes, customizations.

Changelog

Please see the CHANGELOG.md file.