const abuseReportValidator = [
body('account.id')
.optional()
- .custom(isIdValid)
- .withMessage('Should have a valid accountId'),
+ .custom(isIdValid),
body('video.id')
.optional()
.customSanitizer(toCompleteUUID)
- .custom(isIdOrUUIDValid)
- .withMessage('Should have a valid videoId'),
+ .custom(isIdOrUUIDValid),
body('video.startAt')
.optional()
.customSanitizer(toIntOrNull)
- .custom(isAbuseTimestampValid)
- .withMessage('Should have valid starting time value'),
+ .custom(isAbuseTimestampValid),
body('video.endAt')
.optional()
.customSanitizer(toIntOrNull)
.custom(isAbuseTimestampValid)
- .withMessage('Should have valid ending time value')
.bail()
.custom(isAbuseTimestampCoherent)
.withMessage('Should have a startAt timestamp beginning before endAt'),
body('comment.id')
.optional()
- .custom(isIdValid)
- .withMessage('Should have a valid commentId'),
+ .custom(isIdValid),
body('reason')
- .custom(isAbuseReasonValid)
- .withMessage('Should have a valid reason'),
+ .custom(isAbuseReasonValid),
body('predefinedReasons')
.optional()
- .custom(areAbusePredefinedReasonsValid)
- .withMessage('Should have a valid list of predefined reasons'),
+ .custom(areAbusePredefinedReasonsValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking abuseReport parameters', { parameters: req.body })
]
const abuseGetValidator = [
- param('id').custom(isIdValid).not().isEmpty().withMessage('Should have a valid id'),
+ param('id')
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking abuseGetValidator parameters', { parameters: req.body })
]
const abuseUpdateValidator = [
- param('id').custom(isIdValid).not().isEmpty().withMessage('Should have a valid id'),
+ param('id')
+ .custom(isIdValid),
body('state')
.optional()
- .custom(isAbuseStateValid).withMessage('Should have a valid abuse state'),
+ .custom(isAbuseStateValid),
body('moderationComment')
.optional()
- .custom(isAbuseModerationCommentValid).withMessage('Should have a valid moderation comment'),
+ .custom(isAbuseModerationCommentValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking abuseUpdateValidator parameters', { parameters: req.body })
const abuseListForAdminsValidator = [
query('id')
.optional()
- .custom(isIdValid).withMessage('Should have a valid id'),
+ .custom(isIdValid),
query('filter')
.optional()
- .custom(isAbuseFilterValid)
- .withMessage('Should have a valid filter'),
+ .custom(isAbuseFilterValid),
query('predefinedReason')
.optional()
- .custom(isAbusePredefinedReasonValid)
- .withMessage('Should have a valid predefinedReason'),
+ .custom(isAbusePredefinedReasonValid),
query('search')
.optional()
- .custom(exists).withMessage('Should have a valid search'),
+ .custom(exists),
query('state')
.optional()
- .custom(isAbuseStateValid).withMessage('Should have a valid abuse state'),
+ .custom(isAbuseStateValid),
query('videoIs')
.optional()
- .custom(isAbuseVideoIsValid).withMessage('Should have a valid "video is" attribute'),
+ .custom(isAbuseVideoIsValid),
query('searchReporter')
.optional()
- .custom(exists).withMessage('Should have a valid reporter search'),
+ .custom(exists),
query('searchReportee')
.optional()
- .custom(exists).withMessage('Should have a valid reportee search'),
+ .custom(exists),
query('searchVideo')
.optional()
- .custom(exists).withMessage('Should have a valid video search'),
+ .custom(exists),
query('searchVideoChannel')
.optional()
- .custom(exists).withMessage('Should have a valid video channel search'),
+ .custom(exists),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking abuseListForAdminsValidator parameters', { parameters: req.body })
const abuseListForUserValidator = [
query('id')
.optional()
- .custom(isIdValid).withMessage('Should have a valid id'),
+ .custom(isIdValid),
query('search')
.optional()
- .custom(exists).withMessage('Should have a valid search'),
+ .custom(exists),
query('state')
.optional()
- .custom(isAbuseStateValid).withMessage('Should have a valid abuse state'),
+ .custom(isAbuseStateValid),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking abuseListForUserValidator parameters', { parameters: req.body })
]
const getAbuseValidator = [
- param('id').custom(isIdValid).not().isEmpty().withMessage('Should have a valid id'),
+ param('id')
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking getAbuseValidator parameters', { parameters: req.body })
]
const addAbuseMessageValidator = [
- body('message').custom(isAbuseMessageValid).not().isEmpty().withMessage('Should have a valid abuse message'),
+ body('message')
+ .custom(isAbuseMessageValid),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking addAbuseMessageValidator parameters', { parameters: req.body })
]
const deleteAbuseMessageValidator = [
- param('messageId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid message id'),
+ param('messageId')
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking deleteAbuseMessageValidator parameters', { parameters: req.body })
import { areValidationErrors, doesAccountNameWithHostExist, doesLocalAccountNameExist } from './shared'
const localAccountValidator = [
- param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'),
+ param('name')
+ .custom(isAccountNameValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking localAccountValidator parameters', { parameters: req.params })
]
const accountNameWithHostGetValidator = [
- param('accountName').exists().withMessage('Should have an account name with host'),
+ param('accountName')
+ .exists(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking accountsNameWithHostGetValidator parameters', { parameters: req.params })
const apPaginationValidator = [
query('page')
.optional()
- .isInt({ min: 1 }).withMessage('Should have a valid page number'),
+ .isInt({ min: 1 }),
query('size')
.optional()
.isInt({ min: 0, max: PAGINATION.OUTBOX.COUNT.MAX }).withMessage(`Should have a valid page size (max: ${PAGINATION.OUTBOX.COUNT.MAX})`),
const signatureValidator = [
body('signature.type')
.optional()
- .custom(isSignatureTypeValid).withMessage('Should have a valid signature type'),
+ .custom(isSignatureTypeValid),
body('signature.created')
.optional()
.custom(isDateValid).withMessage('Should have a signature created date that conforms to ISO 8601'),
body('signature.creator')
.optional()
- .custom(isSignatureCreatorValid).withMessage('Should have a valid signature creator'),
+ .custom(isSignatureCreatorValid),
body('signature.signatureValue')
.optional()
- .custom(isSignatureValueValid).withMessage('Should have a valid signature value'),
+ .custom(isSignatureValueValid),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking Linked Data Signature parameter', { parameters: { signature: req.body.signature } })
import { areValidationErrors, doesAccountNameWithHostExist } from './shared'
const blockAccountValidator = [
- body('accountName').exists().withMessage('Should have an account name with host'),
+ body('accountName')
+ .exists(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking blockAccountByAccountValidator parameters', { parameters: req.body })
]
const unblockAccountByAccountValidator = [
- param('accountName').exists().withMessage('Should have an account name with host'),
+ param('accountName')
+ .exists(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking unblockAccountByAccountValidator parameters', { parameters: req.params })
]
const unblockAccountByServerValidator = [
- param('accountName').exists().withMessage('Should have an account name with host'),
+ param('accountName')
+ .exists(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking unblockAccountByServerValidator parameters', { parameters: req.params })
]
const blockServerValidator = [
- body('host').custom(isHostValid).withMessage('Should have a valid host'),
+ body('host')
+ .custom(isHostValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking serverGetValidator parameters', { parameters: req.body })
]
const unblockServerByAccountValidator = [
- param('host').custom(isHostValid).withMessage('Should have an account name with host'),
+ param('host')
+ .custom(isHostValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking unblockServerByAccountValidator parameters', { parameters: req.params })
]
const unblockServerByServerValidator = [
- param('host').custom(isHostValid).withMessage('Should have an account name with host'),
+ param('host')
+ .custom(isHostValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking unblockServerByServerValidator parameters', { parameters: req.params })
import { areValidationErrors, doesAccountNameWithHostExist } from './shared'
const bulkRemoveCommentsOfValidator = [
- body('accountName').exists().withMessage('Should have an account name with host'),
+ body('accountName')
+ .exists(),
body('scope')
- .custom(isBulkRemoveCommentsOfScopeValid).withMessage('Should have a valid scope'),
+ .custom(isBulkRemoveCommentsOfScopeValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking bulkRemoveCommentsOfValidator parameters', { parameters: req.body })
import { HttpStatusCode } from '@shared/models/http/http-error-codes'
const customConfigUpdateValidator = [
- body('instance.name').exists().withMessage('Should have a valid instance name'),
- body('instance.shortDescription').exists().withMessage('Should have a valid instance short description'),
- body('instance.description').exists().withMessage('Should have a valid instance description'),
- body('instance.terms').exists().withMessage('Should have a valid instance terms'),
- body('instance.defaultNSFWPolicy').custom(isUserNSFWPolicyValid).withMessage('Should have a valid NSFW policy'),
- body('instance.defaultClientRoute').exists().withMessage('Should have a valid instance default client route'),
- body('instance.customizations.css').exists().withMessage('Should have a valid instance CSS customization'),
- body('instance.customizations.javascript').exists().withMessage('Should have a valid instance JavaScript customization'),
-
- body('services.twitter.username').exists().withMessage('Should have a valid twitter username'),
- body('services.twitter.whitelisted').isBoolean().withMessage('Should have a valid twitter whitelisted boolean'),
-
- body('cache.previews.size').isInt().withMessage('Should have a valid previews cache size'),
- body('cache.captions.size').isInt().withMessage('Should have a valid captions cache size'),
- body('cache.torrents.size').isInt().withMessage('Should have a valid torrents cache size'),
-
- body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'),
- body('signup.limit').isInt().withMessage('Should have a valid signup limit'),
- body('signup.requiresEmailVerification').isBoolean().withMessage('Should have a valid requiresEmailVerification boolean'),
- body('signup.minimumAge').isInt().withMessage('Should have a valid minimum age required'),
-
- body('admin.email').isEmail().withMessage('Should have a valid administrator email'),
- body('contactForm.enabled').isBoolean().withMessage('Should have a valid contact form enabled boolean'),
-
- body('user.videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid video quota'),
- body('user.videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily video quota'),
-
- body('videoChannels.maxPerUser').isInt().withMessage('Should have a valid maximum amount of video channels per user'),
-
- body('transcoding.enabled').isBoolean().withMessage('Should have a valid transcoding enabled boolean'),
- body('transcoding.allowAdditionalExtensions').isBoolean().withMessage('Should have a valid additional extensions boolean'),
- body('transcoding.threads').isInt().withMessage('Should have a valid transcoding threads number'),
- body('transcoding.concurrency').isInt({ min: 1 }).withMessage('Should have a valid transcoding concurrency number'),
- body('transcoding.resolutions.0p').isBoolean().withMessage('Should have a valid transcoding 0p resolution enabled boolean'),
- body('transcoding.resolutions.144p').isBoolean().withMessage('Should have a valid transcoding 144p resolution enabled boolean'),
- body('transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'),
- body('transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'),
- body('transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'),
- body('transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'),
- body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'),
- body('transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'),
- body('transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'),
-
- body('transcoding.alwaysTranscodeOriginalResolution').isBoolean()
- .withMessage('Should have a valid always transcode original resolution boolean'),
-
- body('transcoding.webtorrent.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'),
- body('transcoding.hls.enabled').isBoolean().withMessage('Should have a valid hls transcoding enabled boolean'),
-
- body('videoStudio.enabled').isBoolean().withMessage('Should have a valid video studio enabled boolean'),
-
- body('import.videos.concurrency').isInt({ min: 0 }).withMessage('Should have a valid import concurrency number'),
- body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'),
- body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'),
-
- body('import.videoChannelSynchronization.enabled').isBoolean().withMessage('Should have a valid synchronization enabled boolean'),
-
- body('trending.videos.algorithms.default').exists().withMessage('Should have a valid default trending algorithm'),
- body('trending.videos.algorithms.enabled').exists().withMessage('Should have a valid array of enabled trending algorithms'),
-
- body('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'),
- body('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'),
-
- body('theme.default').custom(v => isThemeNameValid(v) && isThemeRegistered(v)).withMessage('Should have a valid theme'),
-
- body('broadcastMessage.enabled').isBoolean().withMessage('Should have a valid broadcast message enabled boolean'),
- body('broadcastMessage.message').exists().withMessage('Should have a valid broadcast message'),
- body('broadcastMessage.level').exists().withMessage('Should have a valid broadcast level'),
- body('broadcastMessage.dismissable').isBoolean().withMessage('Should have a valid broadcast dismissable boolean'),
-
- body('live.enabled').isBoolean().withMessage('Should have a valid live enabled boolean'),
- body('live.allowReplay').isBoolean().withMessage('Should have a valid live allow replay boolean'),
- body('live.maxDuration').isInt().withMessage('Should have a valid live max duration'),
- body('live.maxInstanceLives').custom(isIntOrNull).withMessage('Should have a valid max instance lives'),
- body('live.maxUserLives').custom(isIntOrNull).withMessage('Should have a valid max user lives'),
- body('live.transcoding.enabled').isBoolean().withMessage('Should have a valid live transcoding enabled boolean'),
- body('live.transcoding.threads').isInt().withMessage('Should have a valid live transcoding threads'),
- body('live.transcoding.resolutions.144p').isBoolean().withMessage('Should have a valid transcoding 144p resolution enabled boolean'),
- body('live.transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'),
- body('live.transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'),
- body('live.transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'),
- body('live.transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'),
- body('live.transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'),
- body('live.transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'),
- body('live.transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'),
- body('live.transcoding.alwaysTranscodeOriginalResolution').isBoolean()
- .withMessage('Should have a valid always transcode live original resolution boolean'),
-
- body('search.remoteUri.users').isBoolean().withMessage('Should have a remote URI search for users boolean'),
- body('search.remoteUri.anonymous').isBoolean().withMessage('Should have a valid remote URI search for anonymous boolean'),
- body('search.searchIndex.enabled').isBoolean().withMessage('Should have a valid search index enabled boolean'),
- body('search.searchIndex.url').exists().withMessage('Should have a valid search index URL'),
- body('search.searchIndex.disableLocalSearch').isBoolean().withMessage('Should have a valid search index disable local search boolean'),
- body('search.searchIndex.isDefaultSearch').isBoolean().withMessage('Should have a valid search index default enabled boolean'),
+ body('instance.name').exists(),
+ body('instance.shortDescription').exists(),
+ body('instance.description').exists(),
+ body('instance.terms').exists(),
+ body('instance.defaultNSFWPolicy').custom(isUserNSFWPolicyValid),
+ body('instance.defaultClientRoute').exists(),
+ body('instance.customizations.css').exists(),
+ body('instance.customizations.javascript').exists(),
+
+ body('services.twitter.username').exists(),
+ body('services.twitter.whitelisted').isBoolean(),
+
+ body('cache.previews.size').isInt(),
+ body('cache.captions.size').isInt(),
+ body('cache.torrents.size').isInt(),
+
+ body('signup.enabled').isBoolean(),
+ body('signup.limit').isInt(),
+ body('signup.requiresEmailVerification').isBoolean(),
+ body('signup.minimumAge').isInt(),
+
+ body('admin.email').isEmail(),
+ body('contactForm.enabled').isBoolean(),
+
+ body('user.videoQuota').custom(isUserVideoQuotaValid),
+ body('user.videoQuotaDaily').custom(isUserVideoQuotaDailyValid),
+
+ body('videoChannels.maxPerUser').isInt(),
+
+ body('transcoding.enabled').isBoolean(),
+ body('transcoding.allowAdditionalExtensions').isBoolean(),
+ body('transcoding.threads').isInt(),
+ body('transcoding.concurrency').isInt({ min: 1 }),
+ body('transcoding.resolutions.0p').isBoolean(),
+ body('transcoding.resolutions.144p').isBoolean(),
+ body('transcoding.resolutions.240p').isBoolean(),
+ body('transcoding.resolutions.360p').isBoolean(),
+ body('transcoding.resolutions.480p').isBoolean(),
+ body('transcoding.resolutions.720p').isBoolean(),
+ body('transcoding.resolutions.1080p').isBoolean(),
+ body('transcoding.resolutions.1440p').isBoolean(),
+ body('transcoding.resolutions.2160p').isBoolean(),
+
+ body('transcoding.alwaysTranscodeOriginalResolution').isBoolean(),
+
+ body('transcoding.webtorrent.enabled').isBoolean(),
+ body('transcoding.hls.enabled').isBoolean(),
+
+ body('videoStudio.enabled').isBoolean(),
+
+ body('import.videos.concurrency').isInt({ min: 0 }),
+ body('import.videos.http.enabled').isBoolean(),
+ body('import.videos.torrent.enabled').isBoolean(),
+
+ body('import.videoChannelSynchronization.enabled').isBoolean(),
+
+ body('trending.videos.algorithms.default').exists(),
+ body('trending.videos.algorithms.enabled').exists(),
+
+ body('followers.instance.enabled').isBoolean(),
+ body('followers.instance.manualApproval').isBoolean(),
+
+ body('theme.default').custom(v => isThemeNameValid(v) && isThemeRegistered(v)),
+
+ body('broadcastMessage.enabled').isBoolean(),
+ body('broadcastMessage.message').exists(),
+ body('broadcastMessage.level').exists(),
+ body('broadcastMessage.dismissable').isBoolean(),
+
+ body('live.enabled').isBoolean(),
+ body('live.allowReplay').isBoolean(),
+ body('live.maxDuration').isInt(),
+ body('live.maxInstanceLives').custom(isIntOrNull),
+ body('live.maxUserLives').custom(isIntOrNull),
+ body('live.transcoding.enabled').isBoolean(),
+ body('live.transcoding.threads').isInt(),
+ body('live.transcoding.resolutions.144p').isBoolean(),
+ body('live.transcoding.resolutions.240p').isBoolean(),
+ body('live.transcoding.resolutions.360p').isBoolean(),
+ body('live.transcoding.resolutions.480p').isBoolean(),
+ body('live.transcoding.resolutions.720p').isBoolean(),
+ body('live.transcoding.resolutions.1080p').isBoolean(),
+ body('live.transcoding.resolutions.1440p').isBoolean(),
+ body('live.transcoding.resolutions.2160p').isBoolean(),
+ body('live.transcoding.alwaysTranscodeOriginalResolution').isBoolean(),
+
+ body('search.remoteUri.users').isBoolean(),
+ body('search.remoteUri.anonymous').isBoolean(),
+ body('search.searchIndex.enabled').isBoolean(),
+ body('search.searchIndex.url').exists(),
+ body('search.searchIndex.disableLocalSearch').isBoolean(),
+ body('search.searchIndex.isDefaultSearch').isBoolean(),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body })
} from './shared'
const feedsFormatValidator = [
- param('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
- query('format').optional().custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)')
+ param('format')
+ .optional()
+ .custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
+ query('format')
+ .optional()
+ .custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
+
+ (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ logger.debug('Checking feeds format parameters', { parameters: req.query })
+
+ if (areValidationErrors(req, res)) return
+
+ return next()
+ }
]
function setFeedFormatContentType (req: express.Request, res: express.Response, next: express.NextFunction) {
const videoFeedsValidator = [
query('accountId')
.optional()
- .custom(isIdValid)
- .withMessage('Should have a valid account id'),
+ .custom(isIdValid),
query('accountName')
.optional(),
query('videoChannelId')
.optional()
- .custom(isIdValid)
- .withMessage('Should have a valid channel id'),
+ .custom(isIdValid),
query('videoChannelName')
.optional(),
const videoSubscriptionFeedsValidator = [
query('accountId')
- .custom(isIdValid)
- .withMessage('Should have a valid account id'),
+ .custom(isIdValid),
query('token')
- .custom(exists)
- .withMessage('Should have a token'),
+ .custom(exists),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking subscription feeds parameters', { parameters: req.query })
const videoCommentsFeedsValidator = [
query('videoId')
- .customSanitizer(toCompleteUUID)
.optional()
+ .customSanitizer(toCompleteUUID)
.custom(isIdOrUUIDValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
const listFollowsValidator = [
query('state')
.optional()
- .custom(isFollowStateValid).withMessage('Should have a valid follow state'),
+ .custom(isFollowStateValid),
query('actorType')
.optional()
- .custom(isActorTypeValid).withMessage('Should have a valid actor type'),
+ .custom(isActorTypeValid),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
const removeFollowingValidator = [
param('hostOrHandle')
- .custom(value => isHostValid(value) || isRemoteHandleValid(value))
- .withMessage('Should have a valid host/handle'),
+ .custom(value => isHostValid(value) || isRemoteHandleValid(value)),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking unfollowing parameters', { parameters: req.params })
]
const getFollowerValidator = [
- param('nameWithHost').custom(isValidActorHandle).withMessage('Should have a valid nameWithHost'),
+ param('nameWithHost')
+ .custom(isValidActorHandle),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking get follower parameters', { parameters: req.params })
const listJobsValidator = [
param('state')
- .optional()
- .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'),
+ .optional()
+ .custom(isValidJobState),
query('jobType')
.optional()
- .custom(isValidJobType).withMessage('Should have a valid job state'),
+ .custom(isValidJobType),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking listJobsValidator parameters.', { parameters: req.params, ...lTags() })
const createClientLogValidator = [
body('message')
- .custom(isValidClientLogMessage).withMessage('Should have a valid log message'),
+ .custom(isValidClientLogMessage),
body('url')
- .custom(isUrlValid).withMessage('Should have a valid log url'),
+ .custom(isUrlValid),
body('level')
- .custom(isValidClientLogLevel).withMessage('Should have a valid log message'),
+ .custom(isValidClientLogLevel),
body('stackTrace')
.optional()
- .custom(isValidClientLogStackTrace).withMessage('Should have a valid log stack trace'),
+ .custom(isValidClientLogStackTrace),
body('meta')
.optional()
- .custom(isValidClientLogMeta).withMessage('Should have a valid log meta'),
+ .custom(isValidClientLogMeta),
body('userAgent')
.optional()
- .custom(isValidClientLogUserAgent).withMessage('Should have a valid log user agent'),
+ .custom(isValidClientLogUserAgent),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking createClientLogValidator parameters.', { parameters: req.query })
.custom(isDateValid).withMessage('Should have a start date that conforms to ISO 8601'),
query('level')
.optional()
- .custom(isValidLogLevel).withMessage('Should have a valid level'),
+ .custom(isValidLogLevel),
query('tagsOneOf')
.optional()
.customSanitizer(toArray)
const addPlaybackMetricValidator = [
body('resolution')
- .isInt({ min: 0 }).withMessage('Invalid resolution'),
+ .isInt({ min: 0 }),
body('fps')
.optional()
- .isInt({ min: 0 }).withMessage('Invalid fps'),
+ .isInt({ min: 0 }),
body('playerMode')
- .custom(isValidPlayerMode).withMessage('Invalid playerMode'),
+ .custom(isValidPlayerMode),
body('resolutionChanges')
- .isInt({ min: 0 }).withMessage('Invalid resolutionChanges'),
+ .isInt({ min: 0 }),
body('errors')
- .isInt({ min: 0 }).withMessage('Invalid errors'),
+ .isInt({ min: 0 }),
body('downloadedBytesP2P')
- .isInt({ min: 0 }).withMessage('Invalid downloadedBytesP2P'),
+ .isInt({ min: 0 }),
body('downloadedBytesHTTP')
- .isInt({ min: 0 }).withMessage('Invalid downloadedBytesHTTP'),
+ .isInt({ min: 0 }),
body('uploadedBytesP2P')
- .isInt({ min: 0 }).withMessage('Invalid uploadedBytesP2P'),
+ .isInt({ min: 0 }),
body('videoId')
.customSanitizer(toCompleteUUID)
- .optional()
.custom(isIdOrUUIDValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
}
const oembedValidator = [
- query('url').isURL(isURLOptions).withMessage('Should have a valid url'),
- query('maxwidth').optional().isInt().withMessage('Should have a valid max width'),
- query('maxheight').optional().isInt().withMessage('Should have a valid max height'),
- query('format').optional().isIn([ 'xml', 'json' ]).withMessage('Should have a valid format'),
+ query('url')
+ .isURL(isURLOptions),
+ query('maxwidth')
+ .optional()
+ .isInt(),
+ query('maxheight')
+ .optional()
+ .isInt(),
+ query('format')
+ .optional()
+ .isIn([ 'xml', 'json' ]),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking oembed parameters', { parameters: req.query })
return [
query('start')
.optional()
- .isInt({ min: 0 }).withMessage('Should have a number start'),
+ .isInt({ min: 0 }),
query('count')
.optional()
.isInt({ min: 0, max: PAGINATION.GLOBAL.COUNT.MAX }).withMessage(`Should have a number count (max: ${PAGINATION.GLOBAL.COUNT.MAX})`),
const getPluginValidator = (pluginType: PluginType, withVersion = true) => {
const validators: (ValidationChain | express.Handler)[] = [
- param('pluginName').custom(isPluginNameValid).withMessage('Should have a valid plugin name')
+ param('pluginName')
+ .custom(isPluginNameValid)
]
if (withVersion) {
validators.push(
- param('pluginVersion').custom(isPluginVersionValid).withMessage('Should have a valid plugin version')
+ param('pluginVersion')
+ .custom(isPluginVersionValid)
)
}
}
const getExternalAuthValidator = [
- param('authName').custom(exists).withMessage('Should have a valid auth name'),
+ param('authName')
+ .custom(exists),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking getExternalAuthValidator parameters', { parameters: req.params })
]
const pluginStaticDirectoryValidator = [
- param('staticEndpoint').custom(isSafePath).withMessage('Should have a valid static endpoint'),
+ param('staticEndpoint')
+ .custom(isSafePath),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking pluginStaticDirectoryValidator parameters', { parameters: req.params })
query('pluginType')
.optional()
.customSanitizer(toIntOrNull)
- .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),
+ .custom(isPluginTypeValid),
query('uninstalled')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid uninstalled attribute'),
+ .custom(isBooleanValid),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking listPluginsValidator parameters', { parameters: req.query })
const installOrUpdatePluginValidator = [
body('npmName')
.optional()
- .custom(isNpmPluginNameValid).withMessage('Should have a valid npm name'),
+ .custom(isNpmPluginNameValid),
body('pluginVersion')
.optional()
- .custom(isPluginVersionValid).withMessage('Should have a valid plugin version'),
+ .custom(isPluginVersionValid),
body('path')
.optional()
- .custom(isSafePath).withMessage('Should have a valid safe path'),
+ .custom(isSafePath),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking installOrUpdatePluginValidator parameters', { parameters: req.body })
]
const uninstallPluginValidator = [
- body('npmName').custom(isNpmPluginNameValid).withMessage('Should have a valid npm name'),
+ body('npmName')
+ .custom(isNpmPluginNameValid),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking uninstallPluginValidator parameters', { parameters: req.body })
]
const existingPluginValidator = [
- param('npmName').custom(isNpmPluginNameValid).withMessage('Should have a valid plugin name'),
+ param('npmName')
+ .custom(isNpmPluginNameValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking enabledPluginValidator parameters', { parameters: req.params })
]
const updatePluginSettingsValidator = [
- body('settings').exists().withMessage('Should have settings'),
+ body('settings')
+ .exists(),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking enabledPluginValidator parameters', { parameters: req.body })
const listAvailablePluginsValidator = [
query('search')
.optional()
- .exists().withMessage('Should have a valid search'),
+ .exists(),
query('pluginType')
.optional()
.customSanitizer(toIntOrNull)
- .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),
+ .custom(isPluginTypeValid),
query('currentPeerTubeEngine')
.optional()
- .custom(isPluginVersionValid).withMessage('Should have a valid current peertube engine'),
+ .custom(isPluginVersionValid),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking enabledPluginValidator parameters', { parameters: req.query })
param('resolution')
.customSanitizer(toIntOrNull)
- .custom(exists).withMessage('Should have a valid resolution'),
+ .custom(exists),
param('fps')
.optional()
.customSanitizer(toIntOrNull)
- .custom(exists).withMessage('Should have a valid fps'),
+ .custom(exists),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoFileRedundancyGetValidator parameters', { parameters: req.params })
param('streamingPlaylistType')
.customSanitizer(toIntOrNull)
- .custom(exists).withMessage('Should have a valid streaming playlist type'),
+ .custom(exists),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoPlaylistRedundancyGetValidator parameters', { parameters: req.params })
]
const updateServerRedundancyValidator = [
- param('host').custom(isHostValid).withMessage('Should have a valid host'),
+ param('host')
+ .custom(isHostValid),
+
body('redundancyAllowed')
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid redundancyAllowed attribute'),
+ .custom(isBooleanValid).withMessage('Should have a valid redundancyAllowed boolean'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking updateServerRedundancy parameters', { parameters: req.params })
const listVideoRedundanciesValidator = [
query('target')
- .custom(isVideoRedundancyTarget).withMessage('Should have a valid video redundancies target'),
+ .custom(isVideoRedundancyTarget),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking listVideoRedundanciesValidator parameters', { parameters: req.query })
const addVideoRedundancyValidator = [
body('videoId')
.customSanitizer(toCompleteUUID)
- .custom(isIdOrUUIDValid)
- .withMessage('Should have a valid video id'),
+ .custom(isIdOrUUIDValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking addVideoRedundancyValidator parameters', { parameters: req.query })
const removeVideoRedundancyValidator = [
param('redundancyId')
- .custom(isIdValid)
- .withMessage('Should have a valid redundancy id'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking removeVideoRedundancyValidator parameters', { parameters: req.query })
import { areValidationErrors } from './shared'
const videosSearchValidator = [
- query('search').optional().not().isEmpty().withMessage('Should have a valid search'),
+ query('search')
+ .optional()
+ .not().isEmpty(),
query('host')
.optional()
- .custom(isHostValid).withMessage('Should have a valid host'),
+ .custom(isHostValid),
query('startDate')
.optional()
query('durationMin')
.optional()
- .isInt().withMessage('Should have a valid min duration'),
+ .isInt(),
query('durationMax')
.optional()
- .isInt().withMessage('Should have a valid max duration'),
+ .isInt(),
query('uuids')
.optional()
.toArray()
.customSanitizer(toCompleteUUIDs)
- .custom(areUUIDsValid).withMessage('Should have valid uuids'),
+ .custom(areUUIDsValid).withMessage('Should have valid array of uuid'),
- query('searchTarget').optional().custom(isSearchTargetValid).withMessage('Should have a valid search target'),
+ query('searchTarget')
+ .optional()
+ .custom(isSearchTargetValid),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videos search query', { parameters: req.query })
const videoChannelsListSearchValidator = [
query('search')
.optional()
- .not().isEmpty().withMessage('Should have a valid search'),
+ .not().isEmpty(),
query('host')
.optional()
- .custom(isHostValid).withMessage('Should have a valid host'),
+ .custom(isHostValid),
query('searchTarget')
.optional()
- .custom(isSearchTargetValid).withMessage('Should have a valid search target'),
+ .custom(isSearchTargetValid),
query('handles')
.optional()
.toArray()
- .custom(isNotEmptyStringArray).withMessage('Should have valid handles'),
+ .custom(isNotEmptyStringArray).withMessage('Should have valid array of handles'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking video channels search query', { parameters: req.query })
const videoPlaylistsListSearchValidator = [
query('search')
.optional()
- .not().isEmpty().withMessage('Should have a valid search'),
+ .not().isEmpty(),
query('host')
.optional()
- .custom(isHostValid).withMessage('Should have a valid host'),
+ .custom(isHostValid),
query('searchTarget')
.optional()
- .custom(isSearchTargetValid).withMessage('Should have a valid search target'),
+ .custom(isSearchTargetValid),
query('uuids')
.optional()
.toArray()
.customSanitizer(toCompleteUUIDs)
- .custom(areUUIDsValid).withMessage('Should have valid uuids'),
+ .custom(areUUIDsValid).withMessage('Should have valid array of uuid'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking video playlists search query', { parameters: req.query })
const contactAdministratorValidator = [
body('fromName')
- .custom(isUserDisplayNameValid).withMessage('Should have a valid name'),
+ .custom(isUserDisplayNameValid),
body('fromEmail')
- .isEmail().withMessage('Should have a valid email'),
+ .isEmail(),
body('body')
- .custom(isValidContactBody).withMessage('Should have a valid body'),
+ .custom(isValidContactBody),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking contactAdministratorValidator parameters', { parameters: req.body })
function isValidVideoIdParam (paramName: string) {
return param(paramName)
.customSanitizer(toCompleteUUID)
- .custom(isIdOrUUIDValid).withMessage('Should have a valid video id')
+ .custom(isIdOrUUIDValid).withMessage('Should have a valid video id (id, short UUID or UUID)')
}
function isValidPlaylistIdParam (paramName: string) {
return param(paramName)
.customSanitizer(toCompleteUUID)
- .custom(isIdOrUUIDValid).withMessage('Should have a valid playlist id')
+ .custom(isIdOrUUIDValid).withMessage('Should have a valid playlist id (id, short UUID or UUID)')
}
// ---------------------------------------------------------------------------
function checkSort (sortableColumns: string[], tags: string[] = []) {
return [
- query('sort').optional().isIn(sortableColumns).withMessage('Should have correct sortable column'),
+ query('sort')
+ .optional()
+ .isIn(sortableColumns),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking sort parameters', { parameters: req.query, tags })
import { areValidationErrors } from './shared'
const serveThemeCSSValidator = [
- param('themeName').custom(isPluginNameValid).withMessage('Should have a valid theme name'),
- param('themeVersion').custom(isPluginVersionValid).withMessage('Should have a valid theme version'),
- param('staticEndpoint').custom(isSafePath).withMessage('Should have a valid static endpoint'),
+ param('themeName')
+ .custom(isPluginNameValid),
+ param('themeVersion')
+ .custom(isPluginVersionValid),
+ param('staticEndpoint')
+ .custom(isSafePath),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking serveThemeCSS parameters', { parameters: req.params })
const userHistoryListValidator = [
query('search')
.optional()
- .custom(exists).withMessage('Should have a valid search'),
+ .custom(exists),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking userHistoryListValidator parameters', { parameters: req.query })
const userHistoryRemoveElementValidator = [
param('videoId')
- .custom(isIdValid).withMessage('Should have a valid video id'),
+ .custom(isIdValid),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking userHistoryRemoveElementValidator parameters', { parameters: req.params })
const updateNotificationSettingsValidator = [
body('newVideoFromSubscription')
- .custom(isUserNotificationSettingValid).withMessage('Should have a valid new video from subscription notification setting'),
+ .custom(isUserNotificationSettingValid),
body('newCommentOnMyVideo')
- .custom(isUserNotificationSettingValid).withMessage('Should have a valid new comment on my video notification setting'),
+ .custom(isUserNotificationSettingValid),
body('abuseAsModerator')
- .custom(isUserNotificationSettingValid).withMessage('Should have a valid abuse as moderator notification setting'),
+ .custom(isUserNotificationSettingValid),
body('videoAutoBlacklistAsModerator')
- .custom(isUserNotificationSettingValid).withMessage('Should have a valid video auto blacklist notification setting'),
+ .custom(isUserNotificationSettingValid),
body('blacklistOnMyVideo')
- .custom(isUserNotificationSettingValid).withMessage('Should have a valid new blacklist on my video notification setting'),
+ .custom(isUserNotificationSettingValid),
body('myVideoImportFinished')
- .custom(isUserNotificationSettingValid).withMessage('Should have a valid video import finished video notification setting'),
+ .custom(isUserNotificationSettingValid),
body('myVideoPublished')
- .custom(isUserNotificationSettingValid).withMessage('Should have a valid video published notification setting'),
+ .custom(isUserNotificationSettingValid),
body('commentMention')
- .custom(isUserNotificationSettingValid).withMessage('Should have a valid comment mention notification setting'),
+ .custom(isUserNotificationSettingValid),
body('newFollow')
- .custom(isUserNotificationSettingValid).withMessage('Should have a valid new follow notification setting'),
+ .custom(isUserNotificationSettingValid),
body('newUserRegistration')
- .custom(isUserNotificationSettingValid).withMessage('Should have a valid new user registration notification setting'),
+ .custom(isUserNotificationSettingValid),
body('newInstanceFollower')
- .custom(isUserNotificationSettingValid).withMessage('Should have a valid new instance follower notification setting'),
+ .custom(isUserNotificationSettingValid),
body('autoInstanceFollowing')
- .custom(isUserNotificationSettingValid).withMessage('Should have a valid new instance following notification setting'),
+ .custom(isUserNotificationSettingValid),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking updateNotificationSettingsValidator parameters', { parameters: req.body })
const markAsReadUserNotificationsValidator = [
body('ids')
.optional()
- .custom(isNotEmptyIntArray).withMessage('Should have a valid notification ids to mark as read'),
+ .custom(isNotEmptyIntArray).withMessage('Should have a valid array of notification ids'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking markAsReadUserNotificationsValidator parameters', { parameters: req.body })
import { areValidationErrors } from './shared'
const userSubscriptionListValidator = [
- query('search').optional().not().isEmpty().withMessage('Should have a valid search'),
+ query('search')
+ .optional()
+ .not().isEmpty(),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking userSubscriptionListValidator parameters', { parameters: req.query })
]
const userSubscriptionAddValidator = [
- body('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'),
+ body('uri')
+ .custom(isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking userSubscriptionAddValidator parameters', { parameters: req.body })
const areSubscriptionsExistValidator = [
query('uris')
.customSanitizer(toArray)
- .custom(areValidActorHandles).withMessage('Should have a valid uri array'),
+ .custom(areValidActorHandles).withMessage('Should have a valid array of URIs'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking areSubscriptionsExistValidator parameters', { parameters: req.query })
]
const userSubscriptionGetValidator = [
- param('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to unfollow'),
+ param('uri')
+ .custom(isValidActorHandle),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking userSubscriptionGetValidator parameters', { parameters: req.params })
query('blocked')
.optional()
.customSanitizer(toBooleanOrNull)
- .isBoolean().withMessage('Should be a valid boolean banned state'),
+ .isBoolean().withMessage('Should be a valid blocked boolena'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersList parameters', { parameters: req.query })
]
const usersAddValidator = [
- body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'),
- body('password').custom(isUserPasswordValidOrEmpty).withMessage('Should have a valid password'),
- body('email').isEmail().withMessage('Should have a valid email'),
+ body('username')
+ .custom(isUserUsernameValid)
+ .withMessage('Should have a valid username (lowercase alphanumeric characters)'),
+ body('password')
+ .custom(isUserPasswordValidOrEmpty),
+ body('email')
+ .isEmail(),
- body('channelName').optional().custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'),
+ body('channelName')
+ .optional()
+ .custom(isVideoChannelUsernameValid),
- body('videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'),
- body('videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'),
+ body('videoQuota')
+ .custom(isUserVideoQuotaValid),
+ body('videoQuotaDaily')
+ .custom(isUserVideoQuotaDailyValid),
body('role')
.customSanitizer(toIntOrNull)
- .custom(isUserRoleValid).withMessage('Should have a valid role'),
- body('adminFlags').optional().custom(isUserAdminFlagsValid).withMessage('Should have a valid admin flags'),
+ .custom(isUserRoleValid),
+
+ body('adminFlags')
+ .optional()
+ .custom(isUserAdminFlagsValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersAdd parameters', { parameters: omit(req.body, 'password') })
]
const usersRegisterValidator = [
- body('username').custom(isUserUsernameValid).withMessage('Should have a valid username'),
- body('password').custom(isUserPasswordValid).withMessage('Should have a valid password'),
- body('email').isEmail().withMessage('Should have a valid email'),
+ body('username')
+ .custom(isUserUsernameValid),
+ body('password')
+ .custom(isUserPasswordValid),
+ body('email')
+ .isEmail(),
body('displayName')
.optional()
- .custom(isUserDisplayNameValid).withMessage('Should have a valid display name'),
+ .custom(isUserDisplayNameValid),
body('channel.name')
.optional()
- .custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'),
+ .custom(isVideoChannelUsernameValid),
body('channel.displayName')
.optional()
- .custom(isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'),
+ .custom(isVideoChannelDisplayNameValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersRegister parameters', { parameters: omit(req.body, 'password') })
]
const usersRemoveValidator = [
- param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),
+ param('id')
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersRemove parameters', { parameters: req.params })
]
const usersBlockingValidator = [
- param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),
- body('reason').optional().custom(isUserBlockedReasonValid).withMessage('Should have a valid blocking reason'),
+ param('id')
+ .custom(isIdValid),
+ body('reason')
+ .optional()
+ .custom(isUserBlockedReasonValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersBlocking parameters', { parameters: req.params })
]
const usersUpdateValidator = [
- param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),
-
- body('password').optional().custom(isUserPasswordValid).withMessage('Should have a valid password'),
- body('email').optional().isEmail().withMessage('Should have a valid email attribute'),
- body('emailVerified').optional().isBoolean().withMessage('Should have a valid email verified attribute'),
- body('videoQuota').optional().custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'),
- body('videoQuotaDaily').optional().custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'),
- body('pluginAuth').optional(),
+ param('id').custom(isIdValid),
+
+ body('password')
+ .optional()
+ .custom(isUserPasswordValid),
+ body('email')
+ .optional()
+ .isEmail(),
+ body('emailVerified')
+ .optional()
+ .isBoolean(),
+ body('videoQuota')
+ .optional()
+ .custom(isUserVideoQuotaValid),
+ body('videoQuotaDaily')
+ .optional()
+ .custom(isUserVideoQuotaDailyValid),
+ body('pluginAuth')
+ .optional()
+ .exists(),
body('role')
.optional()
.customSanitizer(toIntOrNull)
- .custom(isUserRoleValid).withMessage('Should have a valid role'),
- body('adminFlags').optional().custom(isUserAdminFlagsValid).withMessage('Should have a valid admin flags'),
+ .custom(isUserRoleValid),
+ body('adminFlags')
+ .optional()
+ .custom(isUserAdminFlagsValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersUpdate parameters', { parameters: req.body })
const usersUpdateMeValidator = [
body('displayName')
.optional()
- .custom(isUserDisplayNameValid).withMessage('Should have a valid display name'),
+ .custom(isUserDisplayNameValid),
body('description')
.optional()
- .custom(isUserDescriptionValid).withMessage('Should have a valid description'),
+ .custom(isUserDescriptionValid),
body('currentPassword')
.optional()
- .custom(isUserPasswordValid).withMessage('Should have a valid current password'),
+ .custom(isUserPasswordValid),
body('password')
.optional()
- .custom(isUserPasswordValid).withMessage('Should have a valid password'),
+ .custom(isUserPasswordValid),
body('email')
.optional()
- .isEmail().withMessage('Should have a valid email attribute'),
+ .isEmail(),
body('nsfwPolicy')
.optional()
- .custom(isUserNSFWPolicyValid).withMessage('Should have a valid display Not Safe For Work policy'),
+ .custom(isUserNSFWPolicyValid),
body('autoPlayVideo')
.optional()
- .custom(isUserAutoPlayVideoValid).withMessage('Should have a valid automatically plays video attribute'),
+ .custom(isUserAutoPlayVideoValid),
body('p2pEnabled')
.optional()
.custom(isUserP2PEnabledValid).withMessage('Should have a valid p2p enabled boolean'),
body('videoLanguages')
.optional()
- .custom(isUserVideoLanguages).withMessage('Should have a valid video languages attribute'),
+ .custom(isUserVideoLanguages),
body('videosHistoryEnabled')
.optional()
- .custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled attribute'),
+ .custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled boolean'),
body('theme')
.optional()
- .custom(v => isThemeNameValid(v) && isThemeRegistered(v)).withMessage('Should have a valid theme'),
+ .custom(v => isThemeNameValid(v) && isThemeRegistered(v)),
body('noInstanceConfigWarningModal')
.optional()
]
const usersGetValidator = [
- param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),
- query('withStats').optional().isBoolean().withMessage('Should have a valid stats flag'),
+ param('id')
+ .custom(isIdValid),
+ query('withStats')
+ .optional()
+ .isBoolean().withMessage('Should have a valid withStats boolean'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersGet parameters', { parameters: req.params })
query('isLive')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid live boolean'),
+ .custom(isBooleanValid).withMessage('Should have a valid isLive boolean'),
query('channelId')
.optional()
.customSanitizer(toIntOrNull)
- .custom(isIdValid).withMessage('Should have a valid channel id'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersVideosValidator parameters', { parameters: req.query })
]
const usersAskResetPasswordValidator = [
- body('email').isEmail().not().isEmpty().withMessage('Should have a valid email'),
+ body('email')
+ .isEmail(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersAskResetPassword parameters', { parameters: req.body })
]
const usersResetPasswordValidator = [
- param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),
- body('verificationString').not().isEmpty().withMessage('Should have a valid verification string'),
- body('password').custom(isUserPasswordValid).withMessage('Should have a valid password'),
+ param('id')
+ .custom(isIdValid),
+ body('verificationString')
+ .not().isEmpty(),
+ body('password')
+ .custom(isUserPasswordValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersResetPassword parameters', { parameters: req.params })
.custom(isBooleanValid).withMessage('Should have a valid unfederate boolean'),
body('reason')
.optional()
- .custom(isVideoBlacklistReasonValid).withMessage('Should have a valid reason'),
+ .custom(isVideoBlacklistReasonValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videosBlacklistAdd parameters', { parameters: req.params })
isValidVideoIdParam('videoId'),
param('captionLanguage')
- .custom(isVideoCaptionLanguageValid).not().isEmpty().withMessage('Should have a valid caption language'),
+ .custom(isVideoCaptionLanguageValid).not().isEmpty(),
body('captionfile')
.custom((_, { req }) => isVideoCaptionFile(req.files, 'captionfile'))
}
export const videoChannelSyncValidator = [
- body('externalChannelUrl').custom(isUrlValid).withMessage('Should have a valid channel url'),
- body('videoChannelId').isInt().withMessage('Should have a valid video channel id'),
+ body('externalChannelUrl')
+ .custom(isUrlValid),
+
+ body('videoChannelId')
+ .isInt(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoChannelSync parameters', { parameters: req.body })
import { doesVideoChannelSyncIdExist } from '../shared/video-channel-syncs'
export const videoChannelsAddValidator = [
- body('name').custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'),
- body('displayName').custom(isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'),
- body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'),
- body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'),
+ body('name')
+ .custom(isVideoChannelUsernameValid),
+ body('displayName')
+ .custom(isVideoChannelDisplayNameValid),
+ body('description')
+ .optional()
+ .custom(isVideoChannelDescriptionValid),
+ body('support')
+ .optional()
+ .custom(isVideoChannelSupportValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoChannelsAdd parameters', { parameters: req.body })
]
export const videoChannelsUpdateValidator = [
- param('nameWithHost').exists().withMessage('Should have an video channel name with host'),
+ param('nameWithHost')
+ .exists(),
+
body('displayName')
.optional()
- .custom(isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'),
+ .custom(isVideoChannelDisplayNameValid),
body('description')
.optional()
- .custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'),
+ .custom(isVideoChannelDescriptionValid),
body('support')
.optional()
- .custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'),
+ .custom(isVideoChannelSupportValid),
body('bulkVideosSupportUpdate')
.optional()
.custom(isBooleanValid).withMessage('Should have a valid bulkVideosSupportUpdate boolean field'),
]
export const videoChannelsNameWithHostValidator = [
- param('nameWithHost').exists().withMessage('Should have an video channel name with host'),
+ param('nameWithHost')
+ .exists(),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoChannelsNameWithHostValidator parameters', { parameters: req.params })
query('withStats')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid stats flag'),
+ .custom(isBooleanValid).withMessage('Should have a valid stats flag boolean'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
]
export const videoChannelsListValidator = [
- query('search').optional().not().isEmpty().withMessage('Should have a valid search'),
+ query('search')
+ .optional()
+ .not().isEmpty(),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking video channels search query', { parameters: req.query })
]
export const videoChannelImportVideosValidator = [
- body('externalChannelUrl').custom(isUrlValid).withMessage('Should have a valid channel url'),
+ body('externalChannelUrl')
+ .custom(isUrlValid),
body('videoChannelSyncId')
.optional()
- .custom(isIdValid).withMessage('Should have a valid channel sync id'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoChannelImport parameters', { parameters: req.body })
const listVideoCommentsValidator = [
query('isLocal')
- .optional()
- .customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid)
- .withMessage('Should have a valid is local boolean'),
+ .optional()
+ .customSanitizer(toBooleanOrNull)
+ .custom(isBooleanValid)
+ .withMessage('Should have a valid isLocal boolean'),
query('onLocalVideo')
- .optional()
- .customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid)
- .withMessage('Should have a valid is on local video boolean'),
+ .optional()
+ .customSanitizer(toBooleanOrNull)
+ .custom(isBooleanValid)
+ .withMessage('Should have a valid onLocalVideo boolean'),
query('search')
.optional()
- .custom(exists).withMessage('Should have a valid search'),
+ .custom(exists),
query('searchAccount')
.optional()
- .custom(exists).withMessage('Should have a valid account search'),
+ .custom(exists),
query('searchVideo')
.optional()
- .custom(exists).withMessage('Should have a valid video search'),
+ .custom(exists),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking listVideoCommentsValidator parameters.', { parameters: req.query })
isValidVideoIdParam('videoId'),
param('threadId')
- .custom(isIdValid).not().isEmpty().withMessage('Should have a valid threadId'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking listVideoThreadComments parameters.', { parameters: req.params })
isValidVideoIdParam('videoId'),
body('text')
- .custom(isValidVideoCommentText).not().isEmpty().withMessage('Should have a valid comment text'),
+ .custom(isValidVideoCommentText),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking addVideoCommentThread parameters.', { parameters: req.params, body: req.body })
const addVideoCommentReplyValidator = [
isValidVideoIdParam('videoId'),
- param('commentId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid commentId'),
+ param('commentId').custom(isIdValid),
- body('text').custom(isValidVideoCommentText).not().isEmpty().withMessage('Should have a valid comment text'),
+ body('text').custom(isValidVideoCommentText),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking addVideoCommentReply parameters.', { parameters: req.params, body: req.body })
isValidVideoIdParam('videoId'),
param('commentId')
- .custom(isIdValid).not().isEmpty().withMessage('Should have a valid commentId'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoCommentGetValidator parameters.', { parameters: req.params })
const removeVideoCommentValidator = [
isValidVideoIdParam('videoId'),
- param('commentId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid commentId'),
+ param('commentId')
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking removeVideoCommentValidator parameters.', { parameters: req.params })
isValidVideoIdParam('id'),
param('videoFileId')
- .custom(isIdValid).withMessage('Should have a valid file id'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoFilesDeleteWebTorrentFile parameters', { parameters: req.params })
isValidVideoIdParam('id'),
param('videoFileId')
- .custom(isIdValid).withMessage('Should have a valid file id'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoFilesDeleteHLSFile parameters', { parameters: req.params })
const videoImportAddValidator = getCommonVideoEditAttributes().concat([
body('channelId')
.customSanitizer(toIntOrNull)
- .custom(isIdValid).withMessage('Should have correct video channel id'),
+ .custom(isIdValid),
body('targetUrl')
.optional()
- .custom(isVideoImportTargetUrlValid).withMessage('Should have a valid video import target URL'),
+ .custom(isVideoImportTargetUrlValid),
body('magnetUri')
.optional()
- .custom(isVideoMagnetUriValid).withMessage('Should have a valid video magnet URI'),
+ .custom(isVideoMagnetUriValid),
body('torrentfile')
.custom((value, { req }) => isVideoImportTorrentFile(req.files))
.withMessage(
const getMyVideoImportsValidator = [
query('videoChannelSyncId')
.optional()
- .custom(isIdValid).withMessage('Should have correct videoChannelSync id'),
+ .custom(isIdValid),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking getMyVideoImportsValidator parameters', { parameters: req.params })
const videoImportDeleteValidator = [
param('id')
- .custom(isIdValid).withMessage('Should have correct import id'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoImportDeleteValidator parameters', { parameters: req.params })
const videoImportCancelValidator = [
param('id')
- .custom(isIdValid).withMessage('Should have correct import id'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoImportCancelValidator parameters', { parameters: req.params })
const videoLiveAddValidator = getCommonVideoEditAttributes().concat([
body('channelId')
.customSanitizer(toIntOrNull)
- .custom(isIdValid).withMessage('Should have correct video channel id'),
+ .custom(isIdValid),
body('name')
.custom(isVideoNameValid).withMessage(
body('saveReplay')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid saveReplay attribute'),
+ .custom(isBooleanValid).withMessage('Should have a valid saveReplay boolean'),
body('permanentLive')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid permanentLive attribute'),
+ .custom(isBooleanValid).withMessage('Should have a valid permanentLive boolean'),
body('latencyMode')
.optional()
.customSanitizer(toIntOrNull)
- .custom(isLiveLatencyModeValid)
- .withMessage('Should have a valid latency mode attribute'),
+ .custom(isLiveLatencyModeValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoLiveAddValidator parameters', { parameters: req.body })
body('saveReplay')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid saveReplay attribute'),
+ .custom(isBooleanValid).withMessage('Should have a valid saveReplay boolean'),
body('latencyMode')
.optional()
.customSanitizer(toIntOrNull)
- .custom(isLiveLatencyModeValid)
- .withMessage('Should have a valid latency mode attribute'),
+ .custom(isLiveLatencyModeValid),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoLiveUpdateValidator parameters', { parameters: req.body })
const videosTerminateChangeOwnershipValidator = [
param('id')
- .custom(isIdValid).withMessage('Should have a valid id'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking changeOwnership parameters', { parameters: req.params })
const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([
body('displayName')
- .custom(isVideoPlaylistNameValid).withMessage('Should have a valid display name'),
+ .custom(isVideoPlaylistNameValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoPlaylistsAddValidator parameters', { parameters: req.body })
body('displayName')
.optional()
- .custom(isVideoPlaylistNameValid).withMessage('Should have a valid display name'),
+ .custom(isVideoPlaylistNameValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoPlaylistsUpdateValidator parameters', { parameters: req.body })
}
const videoPlaylistsSearchValidator = [
- query('search').optional().not().isEmpty().withMessage('Should have a valid search'),
+ query('search')
+ .optional()
+ .not().isEmpty(),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoPlaylists search query', { parameters: req.query })
body('videoId')
.customSanitizer(toCompleteUUID)
- .custom(isIdOrUUIDValid).withMessage('Should have a valid video id/uuid'),
+ .custom(isIdOrUUIDValid).withMessage('Should have a valid video id/uuid/short uuid'),
body('startTimestamp')
.optional()
- .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid start timestamp'),
+ .custom(isVideoPlaylistTimestampValid),
body('stopTimestamp')
.optional()
- .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid stop timestamp'),
+ .custom(isVideoPlaylistTimestampValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoPlaylistsAddVideoValidator parameters', { parameters: req.params })
isValidPlaylistIdParam('playlistId'),
param('playlistElementId')
.customSanitizer(toCompleteUUID)
- .custom(isIdValid).withMessage('Should have an element id/uuid'),
+ .custom(isIdValid).withMessage('Should have an element id/uuid/short uuid'),
body('startTimestamp')
.optional()
- .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid start timestamp'),
+ .custom(isVideoPlaylistTimestampValid),
body('stopTimestamp')
.optional()
- .custom(isVideoPlaylistTimestampValid).withMessage('Should have a valid stop timestamp'),
+ .custom(isVideoPlaylistTimestampValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoPlaylistsRemoveVideoValidator parameters', { parameters: req.params })
const videoPlaylistElementAPGetValidator = [
isValidPlaylistIdParam('playlistId'),
param('playlistElementId')
- .custom(isIdValid).withMessage('Should have an playlist element id'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoPlaylistElementAPGetValidator parameters', { parameters: req.params })
const videoPlaylistsReorderVideosValidator = [
isValidPlaylistIdParam('playlistId'),
+
body('startPosition')
- .isInt({ min: 1 }).withMessage('Should have a valid start position'),
+ .isInt({ min: 1 }),
body('insertAfterPosition')
- .isInt({ min: 0 }).withMessage('Should have a valid insert after position'),
+ .isInt({ min: 0 }),
body('reorderLength')
.optional()
- .isInt({ min: 1 }).withMessage('Should have a valid range length'),
+ .isInt({ min: 1 }),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoPlaylistsReorderVideosValidator parameters', { parameters: req.params })
const commonVideoPlaylistFiltersValidator = [
query('playlistType')
.optional()
- .custom(isVideoPlaylistTypeValid).withMessage('Should have a valid playlist type'),
+ .custom(isVideoPlaylistTypeValid),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking commonVideoPlaylistFiltersValidator parameters', { parameters: req.params })
body('description')
.optional()
.customSanitizer(toValueOrNull)
- .custom(isVideoPlaylistDescriptionValid).withMessage('Should have a valid description'),
+ .custom(isVideoPlaylistDescriptionValid),
body('privacy')
.optional()
.customSanitizer(toIntOrNull)
- .custom(isVideoPlaylistPrivacyValid).withMessage('Should have correct playlist privacy'),
+ .custom(isVideoPlaylistPrivacyValid),
body('videoChannelId')
.optional()
.customSanitizer(toIntOrNull)
const videoUpdateRateValidator = [
isValidVideoIdParam('id'),
- body('rating').custom(isVideoRatingTypeValid).withMessage('Should have a valid rate type'),
+ body('rating')
+ .custom(isVideoRatingTypeValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoRate parameters', { parameters: req.body })
const getAccountVideoRateValidatorFactory = function (rateType: VideoRateType) {
return [
- param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'),
- param('videoId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid videoId'),
+ param('name')
+ .custom(isAccountNameValid),
+ param('videoId')
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoCommentGetValidator parameters.', { parameters: req.params })
}
const videoRatingValidator = [
- query('rating').optional().custom(isRatingValid).withMessage('Value must be one of "like" or "dislike"'),
+ query('rating')
+ .optional()
+ .custom(isRatingValid).withMessage('Value must be one of "like" or "dislike"'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking rating parameter', { parameters: req.params })
isValidVideoIdParam('id'),
param('actorId')
- .custom(isIdValid).not().isEmpty().withMessage('Should have a valid actor id'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoShare parameters', { parameters: req.params })
query('startDate')
.optional()
- .custom(isDateValid)
- .withMessage('Should have a valid start date'),
+ .custom(isDateValid),
query('endDate')
.optional()
- .custom(isDateValid)
- .withMessage('Should have a valid end date'),
+ .custom(isDateValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoOverallStatsValidator parameters', { parameters: req.body })
isValidVideoIdParam('videoId'),
param('metric')
- .custom(isValidStatTimeserieMetric)
- .withMessage('Should have a valid timeserie metric'),
+ .custom(isValidStatTimeserieMetric),
query('startDate')
.optional()
- .custom(isDateValid)
- .withMessage('Should have a valid start date'),
+ .custom(isDateValid),
query('endDate')
.optional()
- .custom(isDateValid)
- .withMessage('Should have a valid end date'),
+ .custom(isDateValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoTimeserieStatsValidator parameters', { parameters: req.body })
import { areValidationErrors, checkUserCanManageVideo, checkUserQuota, doesVideoExist } from '../shared'
const videoStudioAddEditionValidator = [
- param('videoId').custom(isIdOrUUIDValid).withMessage('Should have a valid video id/uuid'),
+ param('videoId')
+ .custom(isIdOrUUIDValid).withMessage('Should have a valid video id/uuid/short uuid'),
- body('tasks').custom(isValidStudioTasksArray).withMessage('Should have a valid array of tasks'),
+ body('tasks')
+ .custom(isValidStudioTasksArray).withMessage('Should have a valid array of tasks'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoStudioAddEditionValidator parameters.', { parameters: req.params, body: req.body, files: req.files })
isValidVideoIdParam('videoId'),
body('transcodingType')
- .custom(isValidCreateTranscodingType).withMessage('Should have a valid transcoding type'),
+ .custom(isValidCreateTranscodingType),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking createTranscodingValidator parameters', { parameters: req.body })
const getVideoLocalViewerValidator = [
param('localViewerId')
- .custom(isIdValid).withMessage('Should have a valid local viewer id'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking getVideoLocalViewerValidator parameters', { parameters: req.params })
body('currentTime')
.optional() // TODO: remove optional in a few versions, introduced in 4.2
.customSanitizer(toIntOrNull)
- .custom(isIntOrNull).withMessage('Should have correct current time'),
+ .custom(isIntOrNull),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videoView parameters', { parameters: req.body })
),
body('channelId')
.customSanitizer(toIntOrNull)
- .custom(isIdValid).withMessage('Should have correct video channel id'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files })
*/
const videosAddResumableInitValidator = getCommonVideoEditAttributes().concat([
body('filename')
- .isString()
- .exists()
- .withMessage('Should have a valid filename'),
+ .exists(),
body('name')
.trim()
.custom(isVideoNameValid).withMessage(
),
body('channelId')
.customSanitizer(toIntOrNull)
- .custom(isIdValid).withMessage('Should have correct video channel id'),
+ .custom(isIdValid),
header('x-upload-content-length')
.isNumeric()
body('channelId')
.optional()
.customSanitizer(toIntOrNull)
- .custom(isIdValid).withMessage('Should have correct video channel id'),
+ .custom(isIdValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking videosUpdate parameters', { parameters: req.body })
const videosOverviewValidator = [
query('page')
.optional()
- .isInt({ min: 1, max: OVERVIEWS.VIDEOS.SAMPLES_COUNT })
- .withMessage('Should have a valid pagination'),
+ .isInt({ min: 1, max: OVERVIEWS.VIDEOS.SAMPLES_COUNT }),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
body('category')
.optional()
.customSanitizer(toIntOrNull)
- .custom(isVideoCategoryValid).withMessage('Should have a valid category'),
+ .custom(isVideoCategoryValid),
body('licence')
.optional()
.customSanitizer(toIntOrNull)
- .custom(isVideoLicenceValid).withMessage('Should have a valid licence'),
+ .custom(isVideoLicenceValid),
body('language')
.optional()
.customSanitizer(toValueOrNull)
- .custom(isVideoLanguageValid).withMessage('Should have a valid language'),
+ .custom(isVideoLanguageValid),
body('nsfw')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'),
+ .custom(isBooleanValid).withMessage('Should have a valid nsfw boolean'),
body('waitTranscoding')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid wait transcoding attribute'),
+ .custom(isBooleanValid).withMessage('Should have a valid waitTranscoding boolean'),
body('privacy')
.optional()
.customSanitizer(toValueOrNull)
- .custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'),
+ .custom(isVideoPrivacyValid),
body('description')
.optional()
.customSanitizer(toValueOrNull)
- .custom(isVideoDescriptionValid).withMessage('Should have a valid description'),
+ .custom(isVideoDescriptionValid),
body('support')
.optional()
.customSanitizer(toValueOrNull)
- .custom(isVideoSupportValid).withMessage('Should have a valid support text'),
+ .custom(isVideoSupportValid),
body('tags')
.optional()
.customSanitizer(toValueOrNull)
body('commentsEnabled')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have comments enabled boolean'),
+ .custom(isBooleanValid).withMessage('Should have commentsEnabled boolean'),
body('downloadEnabled')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have downloading enabled boolean'),
+ .custom(isBooleanValid).withMessage('Should have downloadEnabled boolean'),
body('originallyPublishedAt')
.optional()
.customSanitizer(toValueOrNull)
- .custom(isVideoOriginallyPublishedAtValid).withMessage('Should have a valid original publication date'),
+ .custom(isVideoOriginallyPublishedAtValid),
body('scheduleUpdate')
.optional()
.customSanitizer(toValueOrNull),
body('scheduleUpdate.privacy')
.optional()
.customSanitizer(toIntOrNull)
- .custom(isScheduleVideoUpdatePrivacyValid).withMessage('Should have correct schedule update privacy')
+ .custom(isScheduleVideoUpdatePrivacyValid)
] as (ValidationChain | ExpressPromiseHandler)[]
}
query('categoryOneOf')
.optional()
.customSanitizer(toArray)
- .custom(isNumberArray).withMessage('Should have a valid one of category array'),
+ .custom(isNumberArray).withMessage('Should have a valid categoryOneOf array'),
query('licenceOneOf')
.optional()
.customSanitizer(toArray)
- .custom(isNumberArray).withMessage('Should have a valid one of licence array'),
+ .custom(isNumberArray).withMessage('Should have a valid licenceOneOf array'),
query('languageOneOf')
.optional()
.customSanitizer(toArray)
- .custom(isStringArray).withMessage('Should have a valid one of language array'),
+ .custom(isStringArray).withMessage('Should have a valid languageOneOf array'),
query('privacyOneOf')
.optional()
.customSanitizer(toArray)
- .custom(isNumberArray).withMessage('Should have a valid one of privacy array'),
+ .custom(isNumberArray).withMessage('Should have a valid privacyOneOf array'),
query('tagsOneOf')
.optional()
.customSanitizer(toArray)
- .custom(isStringArray).withMessage('Should have a valid one of tags array'),
+ .custom(isStringArray).withMessage('Should have a valid tagsOneOf array'),
query('tagsAllOf')
.optional()
.customSanitizer(toArray)
- .custom(isStringArray).withMessage('Should have a valid all of tags array'),
+ .custom(isStringArray).withMessage('Should have a valid tagsAllOf array'),
query('nsfw')
.optional()
- .custom(isBooleanBothQueryValid).withMessage('Should have a valid NSFW attribute'),
+ .custom(isBooleanBothQueryValid),
query('isLive')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid live boolean'),
+ .custom(isBooleanValid).withMessage('Should have a valid isLive boolean'),
query('filter')
.optional()
- .custom(isVideoFilterValid).withMessage('Should have a valid filter attribute'),
+ .custom(isVideoFilterValid),
query('include')
.optional()
- .custom(isVideoIncludeValid).withMessage('Should have a valid include attribute'),
+ .custom(isVideoIncludeValid),
query('isLocal')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid local boolean'),
+ .custom(isBooleanValid).withMessage('Should have a valid isLocal boolean'),
query('hasHLSFiles')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid has hls boolean'),
+ .custom(isBooleanValid).withMessage('Should have a valid hasHLSFiles boolean'),
query('hasWebtorrentFiles')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid has webtorrent boolean'),
+ .custom(isBooleanValid).withMessage('Should have a valid hasWebtorrentFiles boolean'),
query('skipCount')
.optional()
.customSanitizer(toBooleanOrNull)
- .custom(isBooleanValid).withMessage('Should have a valid skip count boolean'),
+ .custom(isBooleanValid).withMessage('Should have a valid skipCount boolean'),
query('search')
.optional()
- .custom(exists).withMessage('Should have a valid search'),
+ .custom(exists),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking commons video filters query', { parameters: req.query })
import { areValidationErrors } from './shared'
const webfingerValidator = [
- query('resource').custom(isWebfingerLocalResourceValid).withMessage('Should have a valid webfinger resource'),
+ query('resource')
+ .custom(isWebfingerLocalResourceValid),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking webfinger parameters', { parameters: req.query })