"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.accountNameWithHostGetValidator = exports.localAccountValidator = void 0;
const tslib_1 = require("tslib");
const express_validator_1 = require("express-validator");
const accounts_1 = require("../../helpers/custom-validators/accounts");
const shared_1 = require("./shared");
const localAccountValidator = [
    (0, express_validator_1.param)('name')
        .custom(accounts_1.isAccountNameValid),
    (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
        if ((0, shared_1.areValidationErrors)(req, res))
            return;
        if (!(yield (0, shared_1.doesLocalAccountNameExist)(req.params.name, res)))
            return;
        return next();
    })
];
exports.localAccountValidator = localAccountValidator;
const accountNameWithHostGetValidator = [
    (0, express_validator_1.param)('accountName')
        .exists(),
    (req, res, next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
        if ((0, shared_1.areValidationErrors)(req, res))
            return;
        if (!(yield (0, shared_1.doesAccountNameWithHostExist)(req.params.accountName, res)))
            return;
        return next();
    })
];
exports.accountNameWithHostGetValidator = accountNameWithHostGetValidator;
//# sourceMappingURL=account.js.map