valpiper
v1.0.6
Published
Pipeline based data validation library
Downloads
2
Readme
Valpiper
Pipeline based data validation library
Valpiper was originally made to make serial data validations (request body => token => request data) easier and more compact.
Installation
NPM:
npm i --save valpiper
Yarn:
yarn add valpiper
The valpiper package also contains type definition file, so you don't need to additionally install @types-package.
Usage example
const Valpiper = require('valpiper').Valpiper;
const vp = new Valpiper();
vp.add('a > b', data => data.a > data.b);
vp.add('ab', data => data.a * data.b < 100);
// Set data and sequence of tests:
console.log(vp.test({a: 8, b: 5}, 'a > b', 'ab'));
// { passed: true, results: [ 'a > b', 'ab' ] }
// Returned object contains status of validation success and array of passed tests.
console.log(vp.test({a: 100, b: 5}, 'a > b', 'ab'));
// { passed: false, results: [ 'a > b' ] }