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

simpul-validate

v0.2.9

Published

Async validation middleware.

Downloads

96

Readme

simpul-validate

An opinionated, fail-fast validation middleware designed for back-end safety, predictability, and performance.

simpul-validate intentionally departs from conventional validation libraries. Rather than attempting to be flexible or UI-friendly, it prioritizes strict server-side validation, deterministic behavior, and clear guarantees at the API boundary.


Installation

npm i simpul-validate

Node v16 Support

npm i [email protected]

Usage

Provide a dictionary with definitions to create a validator and use validator where needed.

const simpul_validate = require("simpul_validate");

const dictionary = [{ key: "name", type: "string", maxLength: 10 }];

const validator = simpul_validate(dictionary);

try {
  const payload = { name: "Ihave A Longname" };

  validator(payload);
} catch (error) {
  // handle error
}

Philosophy & Design

Opinionated by Design

simpul-validate embraces a deliberately opinionated approach to validation. It is optimized for back-end use cases where correctness, performance, and predictability matter more than aggregating multiple errors or loosely accepting input.

This approach goes against many common validation patterns — intentionally.


Fail-Fast Validation

Instead of collecting and returning a list of validation errors, simpul-validate uses a fail-fast model:

  • Validation stops at the first failure
  • An error is thrown immediately
  • Middleware or route handlers can catch and handle the error using their existing error-handling flow

This keeps validation logic simple, avoids branching control flow, and reduces unnecessary work on invalid requests or processing the entirety of large payloads.


Payload Sanitization via Mutation

Sanitization is applied by mutating the original payload, rather than returning a new sanitized object.

This design choice:

  • Avoids unnecessary object allocations
  • Keeps middleware signatures simple
  • Eliminates the need to reassign request bodies or payloads via res locals after validation
  • Aligns naturally with Express / Fastify-style middleware

The result is a cleaner and more ergonomic server-side validation flow.


Exhaustive Dictionary-Based Validation

The validation dictionary is intentionally designed to be exhaustive.

Every possible payload key and value is expected to have a corresponding definition in the dictionary. This ensures:

  • Unknown or unexpected fields are not silently accepted
  • Validation behavior is explicit and deterministic
  • Back-end validation is safer, auditable, and predictable
  • Accidental schema drift is caught early

By requiring full coverage, simpul-validate treats validation as a schema enforcement tool, not just a best-effort checker.


Tradeoffs

This design deliberately trades:

  • Multi-error reporting
  • Partial or permissive schemas
  • UI-centric validation ergonomics

…for:

  • Stronger back-end guarantees
  • Simpler control flow
  • Better performance under load
  • Clear, enforceable API contracts

simpul-validate is best suited for APIs, internal services, and systems where input correctness is non-negotiable and validation is treated as a first-class security and reliability concern.