Skip to content

johnstonskj/node-validate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-validate (validate-type)

This provides a simple is<Type> and assert<Type> module for Node.js. Typically these are used as validators, either for parameter testing or in unit test code.
Build Status

Install

The usual, npm, add a dependency in your package.json to validate-type and run:

$ npm install

API

The module provides very basic isType and assertType functions for testing. All predicates return boolean values, all assertions either return nothing or throw an AssertionError.

var Validate = require('validate-type');

Validate.isInteger(0); // true
Validate.isString(0);  // false;

Validate.assertNumber(1/0); // nothing
Validate.assertArray('');   // Error

Currently the following types are supported:

  • NullOrUndefined
  • String
  • Number
  • Integer
  • Float
  • Boolean
  • Date
  • Array
  • Function

Examples

TBD

About

Simple is<Type> and assert<Type> module for Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published