1 import * as express from 'express'
2 import { param } from 'express-validator/check'
3 import { logger } from '../../helpers'
4 import { isAccountNameValid, isLocalAccountNameExist } from '../../helpers/custom-validators/accounts'
5 import { areValidationErrors } from './utils'
7 const localAccountValidator = [
8 param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'),
10 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
11 logger.debug('Checking localAccountValidator parameters', { parameters: req.params })
13 if (areValidationErrors(req, res)) return
14 if (!await isLocalAccountNameExist(req.params.name, res)) return
20 // ---------------------------------------------------------------------------