@dechamp/express-auto-route
Version:
An express auto route module which allows routes and middleware to be configured via config file.
19 lines (18 loc) • 575 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var Ajv = require("ajv");
function buildError(errors) {
if (errors && errors.length) {
return errors.map(function (error) {
return error.dataPath + ": " + error.message + "\n";
});
}
return false;
}
var jsonSchemaValidationService = function (schema, data) {
var ajv = new Ajv();
var responseValidate = ajv.compile(schema);
responseValidate(data);
return buildError(responseValidate.errors);
};
exports.default = jsonSchemaValidationService;