Skip to content

yoshuawuyts/object-validate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

object-validate

NPM version build status Test coverage Downloads

Validate an object based on a schema.

Installation

$ npm install object-validate

Usage

const validate = require('object-validate')

const schema = validate({
  username: (val) => 'string' == typeof val,
  age:      (val) => /^(\d{1,2})$/.test(val)
})

schema({ username: 'tobi', age: 100 })
// => { username: true, age: false }

Why?

Most data validation tools make assumptions about the type of data you'd want to test. By just using functions as validators we make no assumptions about your data which gives great flexibility.

See Also

License

MIT

About

Validate an object based on a schema

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages