1 import express from 'express'
2 import { param } from 'express-validator'
3 import { isAccountNameValid } from '../../helpers/custom-validators/accounts'
4 import { areValidationErrors, doesAccountNameWithHostExist, doesLocalAccountNameExist } from './shared'
6 const localAccountValidator = [
8 .custom(isAccountNameValid),
10 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
11 if (areValidationErrors(req, res)) return
12 if (!await doesLocalAccountNameExist(req.params.name, res)) return
18 const accountNameWithHostGetValidator = [
22 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
23 if (areValidationErrors(req, res)) return
24 if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return
30 // ---------------------------------------------------------------------------
33 localAccountValidator,
34 accountNameWithHostGetValidator