开发者社区> 镜像站> NPM> object-validate
object-validate
Validate an object based on a schema.
Last updated 6 years ago by yoshuawuyts .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install object-validate 
SYNC missed versions from official npm registry.

object-validate

NPM version build status Test coverage Downloads

Validate an object based on a schema.

Installation

$ npm install object-validate

Usage

var validate = require('object-validate')

var schema = validate({
  username: (val) => 'string' == typeof val,
  age:      (val) => /(\n{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

Current Tags

  • 1.0.0                                ...           latest (6 years ago)

1 Versions

  • 1.0.0                                ...           6 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (3)
Dependents (1)