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

zero-validation

v1.1.2

Published

Zero-validation is a lightweight, fast, and developer-friendly TypeScript validation library with schema-based validation, nested support, and clean error handling.

Readme

zero-validation

Zero-validation is a lightweight, fast, and developer-friendly TypeScript validation library designed for modern applications.

It provides schema-based validation with nested support, clean error handling, and minimal overhead — without the complexity of larger libraries.


Features

  • ⚡ Fast and lightweight
  • 🧩 Schema-based validation
  • 🌳 Nested object & array support
  • ❌ Multi-error handling
  • 🧠 TypeScript-friendly
  • 🧼 Clean and predictable error structure
  • 🔗 Chainable API (min(), required(), etc.)

Installation

npm install zero-validation

Quick Example with safeParse function

import { v } from "zero-validation";

const schema = v.object({
  name: v.string().min(3, "Name too short").required("Name is required"),
  age: v.number().min(18, "Must be adult"),
  tags: v.array(v.string().min(3)).min(1),
  profile: v.object({
    username: v.string().min(2)
  }).required()
});

const result = schema.safeParse({
  name: "Jo",
  age: 16,
  tags: ["ab", "xy"],
  profile: { username: "a" }
});

console.log(result);

Example Output

{
  "success": false,
  "errors": [
    { "field": "name", "message": "Name too short" },
    { "field": "age", "message": "Must be adult" },
    { "field": "tags[0]", "message": "Min 3 characters" },
    { "field": "tags[1]", "message": "Min 3 characters" },
    { "field": "profile.username", "message": "Min 2 characters" }
  ]
}

Example with code as middleware

export const schemaValidation = () => {
  return (req: Request, res: Response, next: NextFunction) => {
    try{
      const result = sampleSchema.safeParse(req.body);
      if(result.success){
        next()
      }else{
          res.status(400).json({
            error: result.errors,
            message: "Invalid request"
          })
      }
    }catch(err){
      res.status(400).json({
        message: err
      })
    }
  }
}

Quick Example with parse function

import { v } from "zero-validation";

const sampleSchema = v.object({
  name: v.string().min(3, "Name too short").required("Name is required"),
  age: v.number().min(18, "Must be adult")
});

const result = sampleSchema.parse({
  name: "Jo",
  age: 16
});

console.log(result);

Example Output

undefined

Example with code as middleware

export const validateSchema = () =>{
  return (req: Request, res: Response, next: NextFunction) => {
    try{
      const result = sampleSchema.parse(req.body);
      next();
    }catch(err){
      res.status(400).json({
        message: err
      })
    }
  }
}

Schema API

String

v.string()
  .min(3, "Minimum 3 characters")
  .required("Required field")
  .nullable();

Number

v.number()
  .min(18, "Must be at least 18")
  .required();

Array

v.array(v.string())
  .min(1, "At least one item required")
  .required();

Object

v.object({
  name: v.string(),
  age: v.number()
}).required();

Validation Methods

parse(data)

  • Throws error if validation fails
export const validateSchema = () =>{
  return (req: Request, res: Response, next: NextFunction) => {
    try{
      const result = sampleSchema.parse(req.body);
      next();
    }catch(err){
      res.status(400).json({
        message: err
      })
    }
  }
}

safeParse(data)

  • Returns structured result
// const result = schema.safeParse(data);

// if (!result.success) {
//   console.log(result.errors);
// }
export const schemaValidation = () => {
  return (req: Request, res: Response, next: NextFunction) => {
    try{
      const result = sampleSchema.safeParse(req.body);
      if(result.success){
        next()
      }else{
          res.status(400).json({
            error: result.errors,
            message: "Invalid request"
          })
      }
    }catch(err){
      res.status(400).json({
        message: err
      })
    }
  }
}

Why zero-validation?

Compared to heavier libraries:

  • 🚀 Faster execution
  • 📦 Smaller bundle size
  • 🧠 Simpler API
  • 🎯 Focused on real-world use cases

Roadmap

  • [ ] .optional() support
  • [ ] .max() validation
  • [ ] Custom validators (.refine())
  • [ ] Transformations (.trim(), .toLowerCase())
  • [ ] Async validation support

Contributing

Contributions are welcome!

Feel free to open issues or submit pull requests.


License

MIT License


Support

If you like this project, consider giving it a star ⭐ on GitHub!