schema-type-validation
Simple library for checking schema types by another schema with reference.
install
npm i schema-type-validation -s
using
const compare = ; //object to referenceconst reference = a: '' b: 0 c: true d : e: 0 ; //setting wrong schemalet to_check = a: 0 b:'' c: 'oi'; //getting the errorslet errors = ;console;// [ // { path: 'a', required: 'string', informed: 'number' },// { path: 'b', required: 'number', informed: 'string' },// { path: 'c', required: 'boolean', informed: 'string' },// { path: 'd.e', required: 'number[]', informed: 'undefined' } // ] //setting right schemato_check = a: 'name' b: 42 c: false d : e: -1 ; //getting the errorserrors = ;console;// [ ]
you can check:
✓ string or string[]
✓ number or number[]
✓ boolean or boolean[]
✓ object or object[]
✓ multiple errors
✓ sublevels validation
Remember, this library is to help verify types, not values.