]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/validators/utils.ts
Fix some grammar (#216)
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / utils.ts
1 import * as express from 'express'
2 import { validationResult } from 'express-validator/check'
3 import { logger } from '../../helpers/logger'
4
5 function areValidationErrors (req: express.Request, res: express.Response) {
6 const errors = validationResult(req)
7
8 if (!errors.isEmpty()) {
9 logger.warn('Incorrect request parameters', { path: req.originalUrl, err: errors.mapped() })
10 res.status(400).json({ errors: errors.mapped() })
11
12 return true
13 }
14
15 return false
16 }
17
18 // ---------------------------------------------------------------------------
19
20 export {
21 areValidationErrors
22 }