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

@jamesadebayo/validator

v1.0.0

Published

A lightweight, rule-based data and form validation package for Node.js with built-in terminal color formatting for validation feedback.

Readme

@jamesadebayo/validator

A lightweight, rule-based data and form validation package for Node.js with built-in terminal color formatting for validation feedback.

Features

  • Pipe-separated Rule Syntax: Define validation rules using simple strings like "required|email" or "required|min:8".
  • Form Object & Single Field Validation: Validate individual input values or complete form data objects.
  • Built-in Rules:
    • required: Ensures values are not null, undefined, "", or whitespace-only strings.
    • email: Validates standard email address formats.
    • min:N: Enforces minimum string length.
    • max:N: Enforces maximum string length.
  • Colorized Console Output: Terminal status output formatted in green (pass), red (fail), and blue (header).

Installation

npm install @jamesadebayo/validator

Usage Examples

1. Form Object Validation

Validate an entire form payload against a schema of rules:

const Validator = require('@jamesadebayo/validator');
const validator = new Validator();

const formData = {
    email: "[email protected]",
    password: ""
};

const formRules = {
    email: "required|email",
    password: "required|min:8"
};

const result = validator.validate(formData, formRules);
console.log(result);

/* Output:
{
  isValid: false,
  errors: {
    password: [ 'password is required' ]
  }
}
*/

2. Single Field Validation

Validate single field inputs using validateField:

// Validate email
const emailResult = validator.validateField("Email", "[email protected]", "required|email");
console.log(emailResult.isValid); // true

// Validate password
const passResult = validator.validateField("Password", "12345", "required|min:8");
console.log(passResult.errors); // ['Password must be at least 8 characters']

3. Helper Methods

Use built-in shorthand methods for quick input checks:

// Email check
console.log(validator.email("[email protected]")); // Validates required + email format

// Password check
console.log(validator.password("mySecretPass123", "required|min:8"));

// Empty field check
console.log(validator.isEmpty("   ")); // true

API Reference

validator.validate(formData, schema)

Validates an object of inputs against a schema object.

  • Returns: { isValid: boolean, errors: Object }

validator.validateField([fieldName], value, rules)

Validates a single field value against a pipe-separated rule string.

  • Returns: { isValid: boolean, errors: string[], message: string }

validator.isEmpty(value)

Checks if a value is empty or whitespace-only.

  • Returns: boolean

License

ISC