diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-25 16:23:44 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-07-25 16:23:44 +0200 |
commit | c8861d5dc0436ef4342ce517241e3591fa256a13 (patch) | |
tree | ca47c09d1f7f1e2aa62c684d576faa938eb47af7 /server/middlewares/validators/videos/video-playlists.ts | |
parent | b4c19345c19b0891142c69308cd9447f2161188c (diff) | |
download | PeerTube-c8861d5dc0436ef4342ce517241e3591fa256a13.tar.gz PeerTube-c8861d5dc0436ef4342ce517241e3591fa256a13.tar.zst PeerTube-c8861d5dc0436ef4342ce517241e3591fa256a13.zip |
Fix express validator
Diffstat (limited to 'server/middlewares/validators/videos/video-playlists.ts')
-rw-r--r-- | server/middlewares/validators/videos/video-playlists.ts | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts index 638122a2e..2e9c8aa33 100644 --- a/server/middlewares/validators/videos/video-playlists.ts +++ b/server/middlewares/validators/videos/video-playlists.ts | |||
@@ -1,12 +1,20 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param, query, ValidationChain } from 'express-validator/check' | 2 | import { body, param, query, ValidationChain } from 'express-validator' |
3 | import { UserRight, VideoPlaylistCreate, VideoPlaylistUpdate } from '../../../../shared' | 3 | import { UserRight, VideoPlaylistCreate, VideoPlaylistUpdate } from '../../../../shared' |
4 | import { logger } from '../../../helpers/logger' | 4 | import { logger } from '../../../helpers/logger' |
5 | import { UserModel } from '../../../models/account/user' | 5 | import { UserModel } from '../../../models/account/user' |
6 | import { areValidationErrors } from '../utils' | 6 | import { areValidationErrors } from '../utils' |
7 | import { isVideoImage } from '../../../helpers/custom-validators/videos' | 7 | import { isVideoImage } from '../../../helpers/custom-validators/videos' |
8 | import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' | 8 | import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' |
9 | import { isArrayOf, isIdOrUUIDValid, isIdValid, isUUIDValid, toIntArray, toValueOrNull } from '../../../helpers/custom-validators/misc' | 9 | import { |
10 | isArrayOf, | ||
11 | isIdOrUUIDValid, | ||
12 | isIdValid, | ||
13 | isUUIDValid, | ||
14 | toIntArray, | ||
15 | toIntOrNull, | ||
16 | toValueOrNull | ||
17 | } from '../../../helpers/custom-validators/misc' | ||
10 | import { | 18 | import { |
11 | isVideoPlaylistDescriptionValid, | 19 | isVideoPlaylistDescriptionValid, |
12 | isVideoPlaylistNameValid, | 20 | isVideoPlaylistNameValid, |
@@ -374,12 +382,11 @@ function getCommonPlaylistEditAttributes () { | |||
374 | .custom(isVideoPlaylistDescriptionValid).withMessage('Should have a valid description'), | 382 | .custom(isVideoPlaylistDescriptionValid).withMessage('Should have a valid description'), |
375 | body('privacy') | 383 | body('privacy') |
376 | .optional() | 384 | .optional() |
377 | .toInt() | 385 | .customSanitizer(toIntOrNull) |
378 | .custom(isVideoPlaylistPrivacyValid).withMessage('Should have correct playlist privacy'), | 386 | .custom(isVideoPlaylistPrivacyValid).withMessage('Should have correct playlist privacy'), |
379 | body('videoChannelId') | 387 | body('videoChannelId') |
380 | .optional() | 388 | .optional() |
381 | .customSanitizer(toValueOrNull) | 389 | .customSanitizer(toIntOrNull) |
382 | .toInt() | ||
383 | ] as (ValidationChain | express.Handler)[] | 390 | ] as (ValidationChain | express.Handler)[] |
384 | } | 391 | } |
385 | 392 | ||