1 import express from 'express'
2 import { query } from 'express-validator'
3 import { isSearchTargetValid } from '@server/helpers/custom-validators/search'
4 import { isHostValid } from '@server/helpers/custom-validators/servers'
5 import { areUUIDsValid, isDateValid, isNotEmptyStringArray, toCompleteUUIDs } from '../../helpers/custom-validators/misc'
6 import { areValidationErrors } from './shared'
8 const videosSearchValidator = [
19 .custom(isDateValid).withMessage('Should have a start date that conforms to ISO 8601'),
22 .custom(isDateValid).withMessage('Should have a end date that conforms to ISO 8601'),
24 query('originallyPublishedStartDate')
26 .custom(isDateValid).withMessage('Should have a published start date that conforms to ISO 8601'),
27 query('originallyPublishedEndDate')
29 .custom(isDateValid).withMessage('Should have a published end date that conforms to ISO 8601'),
41 .customSanitizer(toCompleteUUIDs)
42 .custom(areUUIDsValid).withMessage('Should have valid array of uuid'),
46 .custom(isSearchTargetValid),
48 (req: express.Request, res: express.Response, next: express.NextFunction) => {
49 if (areValidationErrors(req, res)) return
55 const videoChannelsListSearchValidator = [
66 .custom(isSearchTargetValid),
71 .custom(isNotEmptyStringArray).withMessage('Should have valid array of handles'),
73 (req: express.Request, res: express.Response, next: express.NextFunction) => {
74 if (areValidationErrors(req, res)) return
80 const videoPlaylistsListSearchValidator = [
91 .custom(isSearchTargetValid),
96 .customSanitizer(toCompleteUUIDs)
97 .custom(areUUIDsValid).withMessage('Should have valid array of uuid'),
99 (req: express.Request, res: express.Response, next: express.NextFunction) => {
100 if (areValidationErrors(req, res)) return
106 // ---------------------------------------------------------------------------
109 videosSearchValidator,
110 videoChannelsListSearchValidator,
111 videoPlaylistsListSearchValidator