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 🙏

© 2024 – Pkg Stats / Ryan Hefner

check-validator

v1.0.7

Published

Check valifator nodejs

Downloads

16

Readme

check-validator

Check validation for node.js

build status

Check validator that enables validation on multiple parameters at once.

Instalation and usage

Instalation

npm i check-validator

Basic usage

let CheckValidator = require('check-validator');
let validator =  new CheckValidator();

//examples: hasMinLen, hasMaxLen, isEmail
validator.hasMinLen('Hulk', 5, 'Value cannot be less than 5 characters');
validator.hasMaxLen('Avengers infinity war', 6, 'Value can not be longer than 6 characters');
validator.isEmail('thanos.com', 'Invalid email');

if (!validator.isValid()) {
	console.log('Validation errors');
} else {
	console.log('There were no validation errors');
}

//erros
console.log(validator.errors());

Simple validation

Validation without chaining.

Validations

List of available validations.

String

  • hasMinLen(value, text) (value, min, message) - Check if value is less than the parameter min informed
  • hasMaxLen(value, max, message) - Check if value is bigger than the parameter max informed
  • isFixedLen(value, len, message) - Check if value is different than the parameter len informed
  • isRequired(value, message) - Check if value is required
  • isString(value, message) - Determines if a reference is a String.

Email

  • isEmail(value, message) - Check valid email

Number

  • isNumber(value, message) - Determines if a reference is a Number.
  • isGreaterThan(value, comparer, message) - Is greater than.
  • isGreaterOrEqualsThan(value, comparer, message) - Is greater or equals than.
  • isLowerThan(value, comparer, message) - Is lower than.
  • isLowerOrEqualsThan(value, comparer, message) - Is lower or equals than.
  • areEquals(value, comparer, message) - Are equals.
  • areNotEquals(value, comparer, message) - Are not equals.
  • isBetween(value, from, to, message) - Is between.

Other

  • isUndefined(value, message) - Determines if a reference is undefined.
  • isDate(value, message) - Determines if a value is a date.
  • isArray(value, message) - Determines if a reference is an Array. Alias of Array.isArray.

Props and Methods

| Method/Prop | Desc | Test | Status | async | |---|---|---|---|---| | errors | Return a list of errors | OK | Ready | NO | | clear () | Clear the error list | OK | Ready | NO | | isValid () | verify the validity | OK | Ready | NO | | isRequired (val, message) | | OK | Ready | NO | | isString (val, message) | | OK | Ready | NO | | hasMinLen (val, min, message) | | OK | Ready | NO | | hasMaxLen (val, max, message) | | OK | Ready | NO | | isFixedLen (val, len, message) | | OK | Ready | NO | | isEmail (email, message) | | OK | Ready | NO | | isUndefined (value, message | | OK | Ready | NO | | isDate (value, message) | | OK | Ready | NO | | isArray (value, message) | | OK | Ready | NO | | isNumber (value, message) | | OK | Ready | NO | | isGreaterThan (value, comparer, message) | | OK | Ready | NO | | isGreaterOrEqualsThan (value, comparer, message) | | OK | Ready | NO | | isLowerThan (value, comparer, message) | | OK | Ready | NO | | isLowerOrEqualsThan (value, comparer, message) | | OK | Ready | NO | | areEquals (value, comparer, message) | | OK | Ready | NO | | areNotEquals (value, comparer, message) | | OK | Ready | NO | | isBetween (value, from, to, message) | | OK | Ready | NO |