0.4.0 • Published 5 years ago

validate-easy v0.4.0

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

Build Status Coverage Status

Validate easy

(wip) Validate your data easy with pipeline style.

Install

npm install validate-easy

Usage

import _ from 'lodash';
import v from 'validate-easy';

const data = v.assert(
  v.hasProps('foo', 'bar', 'baz'),
  v.path('foo')(v.isNumber, v.lt(10), v.gt(0)),
  v.path('bar')(_.trim, Number, v.isInt)
)({
  foo: 5,
  bar: ' 4',
  baz: null
})

console.log(data);
// result
// {
//   foo: 5,
//   bar: 4,
//   baz: null
// }

TODO

  • pipe function
  • build for node and browser
  • async validator