Last active
June 19, 2017 22:57
-
-
Save vinicius73/0556e3ff0acd1e5d273459b3786ef919 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Joi = require('joi') | |
const ensureJoiSchema = schema => (req, res, next) => { | |
Joi.validate(req.body, schema, (err, value) => { | |
if (err) { | |
res.json(err, 400) | |
next(false) | |
return | |
} | |
req.$requestData = value | |
next() | |
}) | |
} | |
module.exports = ensureJoiSchema |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment