Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rxon/8f4c64b3af119ffe7151b5fbeeacd215 to your computer and use it in GitHub Desktop.
Save rxon/8f4c64b3af119ffe7151b5fbeeacd215 to your computer and use it in GitHub Desktop.
function isCorrectSchema(req, res, next) {
const ajv = new require('ajv')();
const valid = ajv.validate(schema, req.body);
if (!valid) {
res.status(400).send('Bad Request: ${ajv.errors}');
}
return next();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment