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

is.valid

v0.5.3

Published

validation library that is heavily inspired from the old famous codeigniter validation library

Downloads

227

Readme

is.valid

Build Status

Validation library for node.js inspired from the old famous codeigniter validation library.

How to use

Install from npm

npm install is.valid

Instantiate a new is.valid object

var IsValid = require('is.valid');

/** construct a new is.valid object passing the data array to validate
  * date array should contain a set of objects formatted as following
  * {fieldName: value}
 */
var data = {
	name: 'foo bar',
	email: '[email protected]'
}
var isValid = new IsValid(data);

Add validation rules

/**
  * to add validation rules use addRule function
  * addRule accepts 3 arguments
  * field Name as in data object
  * friendly Name for error messages
  * rules separated by |
  * rule is specified by a name and optionaly options
  * like for minLength you should also submit what is the minimum length
  * using the brackets way [10]
 **/
isValid.addRule('name', 'Name', 'required|minLength[10]');

Run validation rules

/**
  * run function go through all validation rules you specified for all fields
  * it accepts a callback function
  * where err is an array contains all error messages formatted like
  * {fieldName: errorMessage }
  * or null if no errors have been found
  * and data is the data object
 **/
isValid.run(function(err, data){

});

Validation functions

required: validates that a value exists

minLength[l]: validates that a value length is at minimum equal to l

maxLength[l]: validates that a value length is at maximum equal to l

exactLength[l]: validates that a value length is exactly l

greaterThan[l]: validate that a value is greater than l

lessThan[l]: validates that a value is less than l

alpha: validates that a value contains only alphabet letters [A-Za-z]

alphaNumeric: validates that a value contains only alphabet letters or numbers [A-Za-z0-9]

alphaNumericDash: validates that a value contains only alphabet letters, numbers or dash [A-Za-z0-9-]

numeric: validates that a value is numeric [0-9]

integer: validates that a value is an integer

decimal: validates that a value is a decimal number

natural: validates that a value is a natural number >= 0

naturalNoZero: validates that a value is a natural number and greater than zero

email: validates that a value looks like an email

regex[s]: validates that a value matches the given regular expressions s

matches[f]: validates that a value matches a value of another field f

list: validates that a value is a list

minListLength[l]: validates that a list has a minimum length l

maxListLength[l]: validates that a list doesn't exceed a maximum length l

date: validates that a value is an actual date

beforeDate[l]: validates that a date is earlier than another date l

afterDate[l]: validates that a date is later than another date l

boolean: validates that a value is either true or false

sanitize: sanitize a value against any possible xss attacks