From 4e50b6a1c9a3eb261e04ede73241648e6edf21d6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 27 Nov 2017 14:44:51 +0100 Subject: Add shares forward and collection on videos/video channels --- server/middlewares/validators/utils.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'server/middlewares/validators/utils.ts') diff --git a/server/middlewares/validators/utils.ts b/server/middlewares/validators/utils.ts index ea107bbe8..77a1a0d4b 100644 --- a/server/middlewares/validators/utils.ts +++ b/server/middlewares/validators/utils.ts @@ -14,8 +14,22 @@ function checkErrors (req: express.Request, res: express.Response, next: express return next() } +function areValidationErrors (req: express.Request, res: express.Response) { + const errors = validationResult(req) + + if (!errors.isEmpty()) { + logger.warn('Incorrect request parameters', { path: req.originalUrl, err: errors.mapped() }) + res.status(400).json({ errors: errors.mapped() }) + + return true + } + + return false +} + // --------------------------------------------------------------------------- export { - checkErrors + checkErrors, + areValidationErrors } -- cgit v1.2.3