]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/middlewares/validators/utils.ts
Fix lint
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / utils.ts
CommitLineData
b60e5f38 1import { validationResult } from 'express-validator/check'
69818c93 2import * as express from 'express'
34ca3b52 3
65fcc311 4import { logger } from '../../helpers'
c45f7f84 5
8a02bd04 6function checkErrors (req: express.Request, res: express.Response, next: express.NextFunction) {
b60e5f38 7 const errors = validationResult(req)
34ca3b52 8
b60e5f38
C
9 if (!errors.isEmpty()) {
10 logger.warn('Incorrect request parameters', { path: req.originalUrl, err: errors.mapped() })
8a02bd04 11 return res.status(400).json({ errors: errors.mapped() })
34ca3b52
C
12 }
13
9f10b292
C
14 return next()
15}
16
17// ---------------------------------------------------------------------------
c45f7f84 18
65fcc311
C
19export {
20 checkErrors
21}