Fix express validator
This commit is contained in:
parent
b4c19345c1
commit
c8861d5dc0
51 changed files with 93 additions and 101 deletions
|
@ -39,7 +39,7 @@ export class InfiniteScrollerDirective implements OnInit, OnDestroy {
|
|||
|
||||
const scrollObservable = fromEvent(this.container || window, 'scroll')
|
||||
.pipe(
|
||||
startWith(null),
|
||||
startWith(null as string), // FIXME: typings
|
||||
throttleTime(200, undefined, throttleOptions),
|
||||
map(() => this.getScrollInfo()),
|
||||
distinctUntilChanged((o1, o2) => o1.current === o2.current),
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
<div class="video-info-privacy">
|
||||
<ng-container *ngIf="displayOptions.privacyText">{{ video.privacy.label }}</ng-container>
|
||||
<ng-container *ngIf="displayOptions.privacyText && displayOptions.state"> - </ng-container>
|
||||
<ng-container *ngIf="displayOptions.privacyText && getStateLabel(video)"> - </ng-container>
|
||||
<ng-container *ngIf="displayOptions.state">{{ getStateLabel(video) }}</ng-container>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -255,10 +255,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
|
|||
)
|
||||
|
||||
// Video did change
|
||||
forkJoin(
|
||||
forkJoin([
|
||||
videoObs,
|
||||
this.videoCaptionService.listCaptions(videoId)
|
||||
)
|
||||
])
|
||||
.pipe(
|
||||
// If 401, the video is private or blacklisted so redirect to 404
|
||||
catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ]))
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import 'express-validator'
|
||||
import { isUserDescriptionValid, isUserUsernameValid } from './users'
|
||||
import { exists } from './misc'
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'multer'
|
||||
import * as validator from 'validator'
|
||||
import { sep } from 'path'
|
||||
import toBoolean = require('validator/lib/toBoolean')
|
||||
|
||||
function exists (value: any) {
|
||||
return value !== undefined && value !== null
|
||||
|
@ -46,9 +47,21 @@ function isBooleanValid (value: any) {
|
|||
}
|
||||
|
||||
function toIntOrNull (value: string) {
|
||||
if (value === 'null') return null
|
||||
const v = toValueOrNull(value)
|
||||
|
||||
return validator.toInt(value)
|
||||
if (v === null || v === undefined) return v
|
||||
if (typeof v === 'number') return v
|
||||
|
||||
return validator.toInt(v)
|
||||
}
|
||||
|
||||
function toBooleanOrNull (value: any) {
|
||||
const v = toValueOrNull(value)
|
||||
|
||||
if (v === null || v === undefined) return v
|
||||
if (typeof v === 'boolean') return v
|
||||
|
||||
return toBoolean(v)
|
||||
}
|
||||
|
||||
function toValueOrNull (value: string) {
|
||||
|
@ -110,6 +123,7 @@ export {
|
|||
isIdOrUUIDValid,
|
||||
isDateValid,
|
||||
toValueOrNull,
|
||||
toBooleanOrNull,
|
||||
isBooleanValid,
|
||||
toIntOrNull,
|
||||
toArray,
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import * as validator from 'validator'
|
||||
import 'express-validator'
|
||||
|
||||
import { isArray } from './misc'
|
||||
|
||||
function isNumberArray (value: any) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import * as validator from 'validator'
|
||||
import 'express-validator'
|
||||
|
||||
import { isArray, exists } from './misc'
|
||||
import { exists, isArray } from './misc'
|
||||
import { isTestInstance } from '../core-utils'
|
||||
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import 'express-validator'
|
||||
import * as validator from 'validator'
|
||||
import { UserRole } from '../../../shared'
|
||||
import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants'
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import 'express-validator'
|
||||
import 'multer'
|
||||
import * as validator from 'validator'
|
||||
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
|
||||
import { exists } from './misc'
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import 'express-validator'
|
||||
import 'multer'
|
||||
import * as validator from 'validator'
|
||||
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import 'express-validator'
|
||||
import 'multer'
|
||||
import * as validator from 'validator'
|
||||
import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_IMPORT_STATES } from '../../initializers/constants'
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import { Response } from 'express'
|
||||
import 'express-validator'
|
||||
import { values } from 'lodash'
|
||||
import 'multer'
|
||||
import * as validator from 'validator'
|
||||
import { UserRight, VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared'
|
||||
import { VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared'
|
||||
import {
|
||||
CONSTRAINTS_FIELDS,
|
||||
MIMETYPES,
|
||||
|
@ -13,9 +10,7 @@ import {
|
|||
VIDEO_RATE_TYPES,
|
||||
VIDEO_STATES
|
||||
} from '../../initializers/constants'
|
||||
import { VideoModel } from '../../models/video/video'
|
||||
import { exists, isArray, isDateValid, isFileValid } from './misc'
|
||||
import { UserModel } from '../../models/account/user'
|
||||
import * as magnetUtil from 'magnet-uri'
|
||||
|
||||
const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import * as OAuthServer from 'express-oauth-server'
|
||||
import 'express-validator'
|
||||
import { OAUTH_LIFETIME } from '../initializers/constants'
|
||||
import { logger } from '../helpers/logger'
|
||||
import { Socket } from 'socket.io'
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import 'express-validator'
|
||||
import * as express from 'express'
|
||||
|
||||
import { PAGINATION } from '../initializers/constants'
|
||||
|
||||
function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import * as express from 'express'
|
||||
import 'express-validator'
|
||||
import { getHostWithPort } from '../helpers/express-utils'
|
||||
|
||||
function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import * as express from 'express'
|
||||
import 'express-validator'
|
||||
import { SortType } from '../models/utils'
|
||||
|
||||
function setDefaultSort (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import * as express from 'express'
|
||||
import 'express-validator'
|
||||
import { UserRight } from '../../shared'
|
||||
import { logger } from '../helpers/logger'
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import { param } from 'express-validator/check'
|
||||
import { param } from 'express-validator'
|
||||
import { isAccountNameValid } from '../../helpers/custom-validators/accounts'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import { body } from 'express-validator/check'
|
||||
import { body } from 'express-validator'
|
||||
import {
|
||||
isSignatureCreatorValid, isSignatureTypeValid,
|
||||
isSignatureValueValid
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import { body } from 'express-validator/check'
|
||||
import { body } from 'express-validator'
|
||||
import { isAvatarFile } from '../../helpers/custom-validators/users'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { body, param } from 'express-validator/check'
|
||||
import { body, param } from 'express-validator'
|
||||
import * as express from 'express'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import { body } from 'express-validator/check'
|
||||
import { body } from 'express-validator'
|
||||
import { isUserNSFWPolicyValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { CustomConfig } from '../../../shared/models/server/custom-config.model'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import { param, query } from 'express-validator/check'
|
||||
import { param, query } from 'express-validator'
|
||||
import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import { body, param } from 'express-validator/check'
|
||||
import { body, param } from 'express-validator'
|
||||
import { isTestInstance } from '../../helpers/core-utils'
|
||||
import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers'
|
||||
import { logger } from '../../helpers/logger'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import { param } from 'express-validator/check'
|
||||
import { param } from 'express-validator'
|
||||
import { isValidJobState } from '../../helpers/custom-validators/jobs'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as express from 'express'
|
|||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { isDateValid } from '../../helpers/custom-validators/misc'
|
||||
import { query } from 'express-validator/check'
|
||||
import { query } from 'express-validator'
|
||||
import { isValidLogLevel } from '../../helpers/custom-validators/logs'
|
||||
|
||||
const getLogsValidator = [
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import { query } from 'express-validator/check'
|
||||
import { query } from 'express-validator'
|
||||
import { join } from 'path'
|
||||
import { isTestInstance } from '../../helpers/core-utils'
|
||||
import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import { query } from 'express-validator/check'
|
||||
import { query } from 'express-validator'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import * as express from 'express'
|
||||
import { body, param, query } from 'express-validator/check'
|
||||
import { body, param, query } from 'express-validator'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
|
||||
import { PluginManager } from '../../lib/plugins/plugin-manager'
|
||||
import { isBooleanValid, isSafePath } from '../../helpers/custom-validators/misc'
|
||||
import { isBooleanValid, isSafePath, toBooleanOrNull } from '../../helpers/custom-validators/misc'
|
||||
import { PluginModel } from '../../models/server/plugin'
|
||||
import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model'
|
||||
import { PluginType } from '../../../shared/models/plugins/plugin.type'
|
||||
|
@ -39,7 +39,7 @@ const listPluginsValidator = [
|
|||
.custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),
|
||||
query('uninstalled')
|
||||
.optional()
|
||||
.toBoolean()
|
||||
.customSanitizer(toBooleanOrNull)
|
||||
.custom(isBooleanValid).withMessage('Should have a valid uninstalled attribute'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import * as express from 'express'
|
||||
import 'express-validator'
|
||||
import { body, param } from 'express-validator/check'
|
||||
import { exists, isBooleanValid, isIdOrUUIDValid, toIntOrNull } from '../../helpers/custom-validators/misc'
|
||||
import { body, param } from 'express-validator'
|
||||
import { exists, isBooleanValid, isIdOrUUIDValid, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
|
||||
|
@ -68,7 +67,7 @@ const videoPlaylistRedundancyGetValidator = [
|
|||
const updateServerRedundancyValidator = [
|
||||
param('host').custom(isHostValid).withMessage('Should have a valid host'),
|
||||
body('redundancyAllowed')
|
||||
.toBoolean()
|
||||
.customSanitizer(toBooleanOrNull)
|
||||
.custom(isBooleanValid).withMessage('Should have a valid redundancyAllowed attribute'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as express from 'express'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { query } from 'express-validator/check'
|
||||
import { query } from 'express-validator'
|
||||
import { isDateValid } from '../../helpers/custom-validators/misc'
|
||||
|
||||
const videosSearchValidator = [
|
||||
|
|
|
@ -3,7 +3,7 @@ import { logger } from '../../helpers/logger'
|
|||
import { areValidationErrors } from './utils'
|
||||
import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers'
|
||||
import { ServerModel } from '../../models/server/server'
|
||||
import { body } from 'express-validator/check'
|
||||
import { body } from 'express-validator'
|
||||
import { isUserDisplayNameValid } from '../../helpers/custom-validators/users'
|
||||
import { Emailer } from '../../lib/emailer'
|
||||
import { Redis } from '../../lib/redis'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import { param } from 'express-validator/check'
|
||||
import { param } from 'express-validator'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import 'express-validator'
|
||||
import { body } from 'express-validator/check'
|
||||
import { body } from 'express-validator'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { isDateValid } from '../../helpers/custom-validators/misc'
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
import * as express from 'express'
|
||||
import 'express-validator'
|
||||
import { body, query } from 'express-validator/check'
|
||||
import { body, query } from 'express-validator'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications'
|
||||
import { isNotEmptyIntArray } from '../../helpers/custom-validators/misc'
|
||||
import { isNotEmptyIntArray, toBooleanOrNull } from '../../helpers/custom-validators/misc'
|
||||
|
||||
const listUserNotificationsValidator = [
|
||||
query('unread')
|
||||
.optional()
|
||||
.toBoolean()
|
||||
.customSanitizer(toBooleanOrNull)
|
||||
.isBoolean().withMessage('Should have a valid unread boolean'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import 'express-validator'
|
||||
import { body, param, query } from 'express-validator/check'
|
||||
import { body, param, query } from 'express-validator'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { ActorFollowModel } from '../../models/activitypub/actor-follow'
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import * as Bluebird from 'bluebird'
|
||||
import * as express from 'express'
|
||||
import 'express-validator'
|
||||
import { body, param } from 'express-validator/check'
|
||||
import { body, param } from 'express-validator'
|
||||
import { omit } from 'lodash'
|
||||
import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
|
||||
import { isIdOrUUIDValid, toIntOrNull } from '../../helpers/custom-validators/misc'
|
||||
import {
|
||||
isUserAdminFlagsValid,
|
||||
isUserAutoPlayVideoValid,
|
||||
|
@ -358,7 +357,7 @@ const usersVerifyEmailValidator = [
|
|||
.not().isEmpty().withMessage('Should have a valid verification string'),
|
||||
body('isPendingEmail')
|
||||
.optional()
|
||||
.toBoolean(),
|
||||
.customSanitizer(toIntOrNull),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersVerifyEmail parameters', { parameters: req.params })
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import { query, validationResult } from 'express-validator/check'
|
||||
import { query, validationResult } from 'express-validator'
|
||||
import { logger } from '../../helpers/logger'
|
||||
|
||||
function areValidationErrors (req: express.Request, res: express.Response) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import 'express-validator'
|
||||
import { body, param } from 'express-validator/check'
|
||||
import { body, param } from 'express-validator'
|
||||
import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors } from '../utils'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as express from 'express'
|
||||
import { body, param, query } from 'express-validator/check'
|
||||
import { isBooleanValid, isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
|
||||
import { body, param, query } from 'express-validator'
|
||||
import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist'
|
||||
|
@ -24,7 +24,7 @@ const videosBlacklistAddValidator = [
|
|||
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
|
||||
body('unfederate')
|
||||
.optional()
|
||||
.toBoolean()
|
||||
.customSanitizer(toBooleanOrNull)
|
||||
.custom(isBooleanValid).withMessage('Should have a valid unfederate boolean'),
|
||||
body('reason')
|
||||
.optional()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as express from 'express'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
|
||||
import { body, param } from 'express-validator/check'
|
||||
import { body, param } from 'express-validator'
|
||||
import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
|
||||
import { UserRight } from '../../../../shared'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import { body, param } from 'express-validator/check'
|
||||
import { body, param } from 'express-validator'
|
||||
import { UserRight } from '../../../../shared'
|
||||
import {
|
||||
isVideoChannelDescriptionValid,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import { body, param } from 'express-validator/check'
|
||||
import { body, param } from 'express-validator'
|
||||
import { UserRight } from '../../../../shared'
|
||||
import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
|
||||
import { isValidVideoCommentText } from '../../../helpers/custom-validators/video-comments'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as express from 'express'
|
||||
import { body } from 'express-validator/check'
|
||||
import { isIdValid } from '../../../helpers/custom-validators/misc'
|
||||
import { body } from 'express-validator'
|
||||
import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { getCommonVideoEditAttributes } from './videos'
|
||||
|
@ -13,7 +13,7 @@ import { doesVideoChannelOfAccountExist } from '../../../helpers/middlewares'
|
|||
|
||||
const videoImportAddValidator = getCommonVideoEditAttributes().concat([
|
||||
body('channelId')
|
||||
.toInt()
|
||||
.customSanitizer(toIntOrNull)
|
||||
.custom(isIdValid).withMessage('Should have correct video channel id'),
|
||||
body('targetUrl')
|
||||
.optional()
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
import * as express from 'express'
|
||||
import { body, param, query, ValidationChain } from 'express-validator/check'
|
||||
import { body, param, query, ValidationChain } from 'express-validator'
|
||||
import { UserRight, VideoPlaylistCreate, VideoPlaylistUpdate } from '../../../../shared'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { UserModel } from '../../../models/account/user'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { isVideoImage } from '../../../helpers/custom-validators/videos'
|
||||
import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
|
||||
import { isArrayOf, isIdOrUUIDValid, isIdValid, isUUIDValid, toIntArray, toValueOrNull } from '../../../helpers/custom-validators/misc'
|
||||
import {
|
||||
isArrayOf,
|
||||
isIdOrUUIDValid,
|
||||
isIdValid,
|
||||
isUUIDValid,
|
||||
toIntArray,
|
||||
toIntOrNull,
|
||||
toValueOrNull
|
||||
} from '../../../helpers/custom-validators/misc'
|
||||
import {
|
||||
isVideoPlaylistDescriptionValid,
|
||||
isVideoPlaylistNameValid,
|
||||
|
@ -374,12 +382,11 @@ function getCommonPlaylistEditAttributes () {
|
|||
.custom(isVideoPlaylistDescriptionValid).withMessage('Should have a valid description'),
|
||||
body('privacy')
|
||||
.optional()
|
||||
.toInt()
|
||||
.customSanitizer(toIntOrNull)
|
||||
.custom(isVideoPlaylistPrivacyValid).withMessage('Should have correct playlist privacy'),
|
||||
body('videoChannelId')
|
||||
.optional()
|
||||
.customSanitizer(toValueOrNull)
|
||||
.toInt()
|
||||
.customSanitizer(toIntOrNull)
|
||||
] as (ValidationChain | express.Handler)[]
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import 'express-validator'
|
||||
import { body, param, query } from 'express-validator/check'
|
||||
import { body, param, query } from 'express-validator'
|
||||
import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
|
||||
import { isRatingValid } from '../../../helpers/custom-validators/video-rates'
|
||||
import { isVideoRatingTypeValid } from '../../../helpers/custom-validators/videos'
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import 'express-validator'
|
||||
import { param } from 'express-validator/check'
|
||||
import { param } from 'express-validator'
|
||||
import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { VideoShareModel } from '../../../models/video/video-share'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { body, param } from 'express-validator/check'
|
||||
import { body, param } from 'express-validator'
|
||||
import * as express from 'express'
|
||||
import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
|
||||
import { isIdOrUUIDValid, toIntOrNull } from '../../../helpers/custom-validators/misc'
|
||||
import { areValidationErrors } from '../utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { doesVideoExist } from '../../../helpers/middlewares'
|
||||
|
@ -8,7 +8,7 @@ import { doesVideoExist } from '../../../helpers/middlewares'
|
|||
const videoWatchingValidator = [
|
||||
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
|
||||
body('currentTime')
|
||||
.toInt()
|
||||
.customSanitizer(toIntOrNull)
|
||||
.isInt().withMessage('Should have correct current time'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import 'express-validator'
|
||||
import { body, param, query, ValidationChain } from 'express-validator/check'
|
||||
import { body, param, query, ValidationChain } from 'express-validator'
|
||||
import { UserRight, VideoChangeOwnershipStatus, VideoPrivacy } from '../../../../shared'
|
||||
import {
|
||||
isBooleanValid,
|
||||
|
@ -9,6 +8,7 @@ import {
|
|||
isIdValid,
|
||||
isUUIDValid,
|
||||
toArray,
|
||||
toBooleanOrNull,
|
||||
toIntOrNull,
|
||||
toValueOrNull
|
||||
} from '../../../helpers/custom-validators/misc'
|
||||
|
@ -53,7 +53,7 @@ const videosAddValidator = getCommonVideoEditAttributes().concat([
|
|||
),
|
||||
body('name').custom(isVideoNameValid).withMessage('Should have a valid name'),
|
||||
body('channelId')
|
||||
.toInt()
|
||||
.customSanitizer(toIntOrNull)
|
||||
.custom(isIdValid).withMessage('Should have correct video channel id'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
|
@ -101,7 +101,7 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([
|
|||
.custom(isVideoNameValid).withMessage('Should have a valid name'),
|
||||
body('channelId')
|
||||
.optional()
|
||||
.toInt()
|
||||
.customSanitizer(toIntOrNull)
|
||||
.custom(isIdValid).withMessage('Should have correct video channel id'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
|
@ -307,15 +307,15 @@ function getCommonVideoEditAttributes () {
|
|||
.custom(isVideoLanguageValid).withMessage('Should have a valid language'),
|
||||
body('nsfw')
|
||||
.optional()
|
||||
.toBoolean()
|
||||
.customSanitizer(toBooleanOrNull)
|
||||
.custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'),
|
||||
body('waitTranscoding')
|
||||
.optional()
|
||||
.toBoolean()
|
||||
.customSanitizer(toBooleanOrNull)
|
||||
.custom(isBooleanValid).withMessage('Should have a valid wait transcoding attribute'),
|
||||
body('privacy')
|
||||
.optional()
|
||||
.toInt()
|
||||
.customSanitizer(toValueOrNull)
|
||||
.custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'),
|
||||
body('description')
|
||||
.optional()
|
||||
|
@ -331,16 +331,16 @@ function getCommonVideoEditAttributes () {
|
|||
.custom(isVideoTagsValid).withMessage('Should have correct tags'),
|
||||
body('commentsEnabled')
|
||||
.optional()
|
||||
.toBoolean()
|
||||
.customSanitizer(toBooleanOrNull)
|
||||
.custom(isBooleanValid).withMessage('Should have comments enabled boolean'),
|
||||
body('downloadEnabled')
|
||||
.optional()
|
||||
.toBoolean()
|
||||
.customSanitizer(toBooleanOrNull)
|
||||
.custom(isBooleanValid).withMessage('Should have downloading enabled boolean'),
|
||||
body('originallyPublishedAt')
|
||||
.optional()
|
||||
.customSanitizer(toValueOrNull)
|
||||
.custom(isVideoOriginallyPublishedAtValid).withMessage('Should have a valid original publication date'),
|
||||
.optional()
|
||||
.customSanitizer(toValueOrNull)
|
||||
.custom(isVideoOriginallyPublishedAtValid).withMessage('Should have a valid original publication date'),
|
||||
body('scheduleUpdate')
|
||||
.optional()
|
||||
.customSanitizer(toValueOrNull),
|
||||
|
@ -349,7 +349,7 @@ function getCommonVideoEditAttributes () {
|
|||
.custom(isDateValid).withMessage('Should have a valid schedule update date'),
|
||||
body('scheduleUpdate.privacy')
|
||||
.optional()
|
||||
.toInt()
|
||||
.customSanitizer(toValueOrNull)
|
||||
.custom(isScheduleVideoUpdatePrivacyValid).withMessage('Should have correct schedule update privacy')
|
||||
] as (ValidationChain | express.Handler)[]
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as express from 'express'
|
||||
import { query } from 'express-validator/check'
|
||||
import { query } from 'express-validator'
|
||||
import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { ActorModel } from '../../models/activitypub/actor'
|
||||
|
|
|
@ -91,7 +91,7 @@ describe('Test video imports API validator', function () {
|
|||
support: 'my super support text',
|
||||
tags: [ 'tag1', 'tag2' ],
|
||||
privacy: VideoPrivacy.PUBLIC,
|
||||
channelId: channelId
|
||||
channelId
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue