aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/utils.ts
diff options
context:
space:
mode:
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}