]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/helpers/custom-validators/video-blacklist.ts
Merge branch 'release/4.0.0' into develop
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / video-blacklist.ts
... / ...
CommitLineData
1import validator from 'validator'
2import { exists } from './misc'
3import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
4import { VideoBlacklistType } from '../../../shared/models/videos'
5
6const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_BLACKLIST
7
8function isVideoBlacklistReasonValid (value: string) {
9 return value === null || validator.isLength(value, VIDEO_BLACKLIST_CONSTRAINTS_FIELDS.REASON)
10}
11
12function isVideoBlacklistTypeValid (value: any) {
13 return exists(value) &&
14 (value === VideoBlacklistType.AUTO_BEFORE_PUBLISHED || value === VideoBlacklistType.MANUAL)
15}
16
17// ---------------------------------------------------------------------------
18
19export {
20 isVideoBlacklistReasonValid,
21 isVideoBlacklistTypeValid
22}