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

nen-validate

v1.0.2

Published

validation package of nen-lab

Downloads

29

Readme

nen-validate

an nodejs validation package

install

yarn add nen-validate

usage

for check some validation rules

const { rules } = require('nen-validate');

const error = rules
  .required()
  .minLen(3)
  .validate('name', 'value');
// error will be one of the below values.
//  - null if all rules were passed.
//  - { [name]: validation error message } when there are any fail rule.

using as koa middleware

const { rules, koaValidate } = require('nen-validate');
//...

const schemas = {
  body: {
    id: rules.required(),
    name: rules.maxLen(100)
  }
};

router.post('/route', koaValidate(schemas), controller);
// if validation not passed it will response 400 with errors

api

required

check if passed value is not null undefined and blank

const { rules } = require('nen-validate');

const check = rules.required();

maxLen

check maximum length of passed value

const { rules } = require('nen-validate');

const check = rules.maxLen(5); // check maximum length is 5

minLen

check minimum length of passed value

const { rules } = require('nen-validate');

const check = rules.minLen(5); // check minimum length is 5

valid

check whether passed value is one of valid values or not

const { rules } = require('nen-validate');

const check = rules.valid(1, 2, 3); // check passed value is one of 1, 2, 3

email

check whether passed value is a valid email or not

const { rules } = require('nen-validate');

const check = rules.email();

regex

check whether passed value is a valid value match to passed regex

const { rules } = require('nen-validate');

const check = rules.regex(/0-9/i);

number

check whether passed value is a number or not

const { rules } = require('nen-validate');

const check = rules.number();

gt

check whether passed number greater than passed compare value or not

const { rules } = require('nen-validate');

const check = rules.gt(5);

gte

check whether passed number greater than or equal passed compare value or not

const { rules } = require('nen-validate');

const check = rules.gte(5);

lt

check whether passed number less than passed compare value or not

const { rules } = require('nen-validate');

const check = rules.lt(5);

lte

check whether passed number less than or equal passed compare value or not

const { rules } = require('nen-validate');

const check = rules.lte(5);

validate

check all attached rule and stop when rule not passed

const { rules } = require('nen-validate');

const errors = rules
  .required()
  .lte(5)
  .validate('aField', 'test');