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 🙏

© 2025 – Pkg Stats / Ryan Hefner

veruniq

v1.1.4

Published

Form Validator declarative, rules sync/async, custom messages, nested path support. Tiny & extensible.

Readme

veruniq — Declarative Form Validator

A small, framework-agnostic JavaScript form validation library that supports declarative schemas, synchronous and asynchronous rules, nested path access, presets, and custom messages. Lightweight and easy to embed in Node or browser bundles.

Install

# from npm (if published)
npm install veruniq

# or use locally
npm install

Quick Start

const { createValidator, registerPreset } = require('./index');

// optional: register a preset
registerPreset('strongPassword', [
  'minLength:8',
  { rule: 'pattern:^(?=.*[A-Z])(?=.*\\d).+$', message: 'Password must include an uppercase letter and a digit' }
]);

const schema = {
  'user.email': ['required', 'email'],
  'password': ['required', 'minLength:6', 'preset:strongPassword'],
  'age': [{ rule: 'min:18', message: 'You must be at least 18' }]
};

const validator = createValidator(schema, { abortEarly: true });

(async () => {
  const { valid, errors } = await validator.validate({
    user: { email: '[email protected]' },
    password: 'Secret1',
    age: 20
  });

  console.log(valid, errors);
  // { valid: true, errors: {} }
})();

API

  • Entry point: index.js
  • createValidator(schema, options) — main factory (see createValidator)
    • options: { abortEarly: boolean (default true), messages: {} }
    • returns an object with .validate(values) => Promise<{ valid, errors }>

Exports:

Core behavior:

  • Supports rule formats: string shorthand (e.g., min:3), object ({ rule, params, message, when }), or custom function (sync or async).
  • Conditional rules via when or dependsOn.
  • Presets allow composing multiple rules under a name (preset:NAME).

Schema examples

  • String shorthand: "required", "email", "min:18", "pattern:^\\d+$"
  • Object rule:
{ rule: 'minLength:6', message: 'Too short' }
  • Function rule (sync or Promise-returning):
async (value, ctx) => {
  const ok = await checkUniqueEmail(value);
  return ok || 'Email already taken';
}

Files of interest

Testing

Run provided tests (if dependencies installed):

npm test

Unit tests and examples are located under the repository test/ and src/example/ (if present).

Contributing

  • Fork the repository, create a branch, add tests for new behavior, and submit a PR.
  • Follow existing code style and keep changes minimal and backwards compatible.

License

MIT — see package.json for license field.