aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/utils.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-27 14:44:51 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:53 +0100
commit4e50b6a1c9a3eb261e04ede73241648e6edf21d6 (patch)
treee1c6c121d561ffc1cf2996daec03a1e7f27f0a25 /server/middlewares/validators/utils.ts
parent74bb2cb8348d6794ed3a0e2ec94c8c9abdde82cf (diff)
downloadPeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.tar.gz
PeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.tar.zst
PeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.zip
Add shares forward and collection on videos/video channels
Diffstat (limited to 'server/middlewares/validators/utils.ts')
-rw-r--r--server/middlewares/validators/utils.ts16
1 files changed, 15 insertions, 1 deletions
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
14 return next() 14 return next()
15} 15}
16 16
17function areValidationErrors (req: express.Request, res: express.Response) {
18 const errors = validationResult(req)
19
20 if (!errors.isEmpty()) {
21 logger.warn('Incorrect request parameters', { path: req.originalUrl, err: errors.mapped() })
22 res.status(400).json({ errors: errors.mapped() })
23
24 return true
25 }
26
27 return false
28}
29
17// --------------------------------------------------------------------------- 30// ---------------------------------------------------------------------------
18 31
19export { 32export {
20 checkErrors 33 checkErrors,
34 areValidationErrors
21} 35}