Add shares forward and collection on videos/video channels
[oweals/peertube.git] / server / middlewares / validators / account.ts
1 import * as express from 'express'
2 import { param } from 'express-validator/check'
3 import { logger } from '../../helpers'
4 import { checkLocalAccountNameExists, isAccountNameValid } from '../../helpers/custom-validators/accounts'
5 import { checkErrors } from './utils'
6
7 const localAccountValidator = [
8   param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'),
9
10   (req: express.Request, res: express.Response, next: express.NextFunction) => {
11     logger.debug('Checking localAccountValidator parameters', { parameters: req.params })
12
13     checkErrors(req, res, () => {
14       checkLocalAccountNameExists(req.params.name, res, next)
15     })
16   }
17 ]
18
19 // ---------------------------------------------------------------------------
20
21 export {
22   localAccountValidator
23 }