Created
January 10, 2021 15:39
-
-
Save Daniel1984/ad72bb888a384794bc21d9bb76e2f97e to your computer and use it in GitHub Desktop.
This file contains 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
// middleware/validateBodyParams.js | |
const validId = require('./validId'); | |
module.exports = (req, res, next) => { | |
const { | |
account_id: accId, | |
currency, | |
} = req.body; | |
if (!accId || !currency) { | |
const err = new Error('missing body params'); | |
err.status = 412; | |
return next(err); | |
} | |
if (!validId(accId)) { | |
const err = new Error('invalid id'); | |
err.status = 400; | |
return next(err); | |
} | |
next(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment