Validation module
This is basically a wrapper of ajv module.
What it does - is accepts a directory with schemas, reads it in an async or sync fashion based on your preference
and caches validators under it's name, minus it's extension (to be completely honest - it strips down .json
only).
Based on the bluebird promises.
Installation
npm i ms-validation -S
Usage
// Lets assume that we have a following file structure://// .// ./schemas/config.json// ./schemas/ping.json// ./index.js// const Errors = ;const Validator = ;const validator = './schemas'; // some logic herevalidator; const result = validator;if resulterror // handle error! // do stuff// ... // init filtervalidator; // all schemas in this dir will filter out additional properties instead of throwing an error // catches when we only have 417 errorsvalidator ;