"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.videoPlaylistsListSearchValidator = exports.videoChannelsListSearchValidator = exports.videosSearchValidator = void 0;
const express_validator_1 = require("express-validator");
const search_1 = require("../../helpers/custom-validators/search");
const servers_1 = require("../../helpers/custom-validators/servers");
const misc_1 = require("../../helpers/custom-validators/misc");
const shared_1 = require("./shared");
const videosSearchValidator = [
    (0, express_validator_1.query)('search')
        .optional()
        .not().isEmpty(),
    (0, express_validator_1.query)('host')
        .optional()
        .custom(servers_1.isHostValid),
    (0, express_validator_1.query)('startDate')
        .optional()
        .custom(misc_1.isDateValid).withMessage('Should have a start date that conforms to ISO 8601'),
    (0, express_validator_1.query)('endDate')
        .optional()
        .custom(misc_1.isDateValid).withMessage('Should have a end date that conforms to ISO 8601'),
    (0, express_validator_1.query)('originallyPublishedStartDate')
        .optional()
        .custom(misc_1.isDateValid).withMessage('Should have a published start date that conforms to ISO 8601'),
    (0, express_validator_1.query)('originallyPublishedEndDate')
        .optional()
        .custom(misc_1.isDateValid).withMessage('Should have a published end date that conforms to ISO 8601'),
    (0, express_validator_1.query)('durationMin')
        .optional()
        .isInt(),
    (0, express_validator_1.query)('durationMax')
        .optional()
        .isInt(),
    (0, express_validator_1.query)('uuids')
        .optional()
        .toArray()
        .customSanitizer(misc_1.toCompleteUUIDs)
        .custom(misc_1.areUUIDsValid).withMessage('Should have valid array of uuid'),
    (0, express_validator_1.query)('searchTarget')
        .optional()
        .custom(search_1.isSearchTargetValid),
    (req, res, next) => {
        if ((0, shared_1.areValidationErrors)(req, res))
            return;
        return next();
    }
];
exports.videosSearchValidator = videosSearchValidator;
const videoChannelsListSearchValidator = [
    (0, express_validator_1.query)('search')
        .optional()
        .not().isEmpty(),
    (0, express_validator_1.query)('host')
        .optional()
        .custom(servers_1.isHostValid),
    (0, express_validator_1.query)('searchTarget')
        .optional()
        .custom(search_1.isSearchTargetValid),
    (0, express_validator_1.query)('handles')
        .optional()
        .toArray()
        .custom(misc_1.isNotEmptyStringArray).withMessage('Should have valid array of handles'),
    (req, res, next) => {
        if ((0, shared_1.areValidationErrors)(req, res))
            return;
        return next();
    }
];
exports.videoChannelsListSearchValidator = videoChannelsListSearchValidator;
const videoPlaylistsListSearchValidator = [
    (0, express_validator_1.query)('search')
        .optional()
        .not().isEmpty(),
    (0, express_validator_1.query)('host')
        .optional()
        .custom(servers_1.isHostValid),
    (0, express_validator_1.query)('searchTarget')
        .optional()
        .custom(search_1.isSearchTargetValid),
    (0, express_validator_1.query)('uuids')
        .optional()
        .toArray()
        .customSanitizer(misc_1.toCompleteUUIDs)
        .custom(misc_1.areUUIDsValid).withMessage('Should have valid array of uuid'),
    (req, res, next) => {
        if ((0, shared_1.areValidationErrors)(req, res))
            return;
        return next();
    }
];
exports.videoPlaylistsListSearchValidator = videoPlaylistsListSearchValidator;
//# sourceMappingURL=search.js.map