diff options
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r-- | server/helpers/custom-validators/video-blacklist.ts | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/video-blacklist.ts b/server/helpers/custom-validators/video-blacklist.ts index 25f908228..465f58a9c 100644 --- a/server/helpers/custom-validators/video-blacklist.ts +++ b/server/helpers/custom-validators/video-blacklist.ts | |||
@@ -1,7 +1,9 @@ | |||
1 | import { Response } from 'express' | 1 | import { Response } from 'express' |
2 | import * as validator from 'validator' | 2 | import * as validator from 'validator' |
3 | import { exists } from './misc' | ||
3 | import { CONSTRAINTS_FIELDS } from '../../initializers' | 4 | import { CONSTRAINTS_FIELDS } from '../../initializers' |
4 | import { VideoBlacklistModel } from '../../models/video/video-blacklist' | 5 | import { VideoBlacklistModel } from '../../models/video/video-blacklist' |
6 | import { VideoBlacklistType } from '../../../shared/models/videos' | ||
5 | 7 | ||
6 | const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_BLACKLIST | 8 | const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_BLACKLIST |
7 | 9 | ||
@@ -24,9 +26,14 @@ async function doesVideoBlacklistExist (videoId: number, res: Response) { | |||
24 | return true | 26 | return true |
25 | } | 27 | } |
26 | 28 | ||
29 | function isVideoBlacklistTypeValid (value: any) { | ||
30 | return exists(value) && validator.isInt('' + value) && VideoBlacklistType[value] !== undefined | ||
31 | } | ||
32 | |||
27 | // --------------------------------------------------------------------------- | 33 | // --------------------------------------------------------------------------- |
28 | 34 | ||
29 | export { | 35 | export { |
30 | isVideoBlacklistReasonValid, | 36 | isVideoBlacklistReasonValid, |
37 | isVideoBlacklistTypeValid, | ||
31 | doesVideoBlacklistExist | 38 | doesVideoBlacklistExist |
32 | } | 39 | } |