Validate your data easy with pipeline style.
Most existing validation libraries are based on the schema, which makes it so heavy and hard to extend.
- Tiny and tree-shaking friendly.
- Easy to extend.
- Easy to combine with other libraries.
- Detailed errors.
npm install validate-easy
import _ from 'lodash';
import * as v from 'validate-easy';
const data = v.v(
v.required('foo', 'bar', 'baz'),
v.prop('foo')(v.isNumber, v.lt(10), v.gt(0)),
v.prop('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