PeerTube/server/helpers/custom-validators/video-blacklist.ts

22 lines
738 B
TypeScript
Raw Normal View History

2018-08-13 16:57:13 +02:00
import * as validator from 'validator'
import { exists } from './misc'
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
import { VideoBlacklistType } from '../../../shared/models/videos'
2018-08-13 16:57:13 +02:00
const VIDEO_BLACKLIST_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_BLACKLIST
function isVideoBlacklistReasonValid (value: string) {
return value === null || validator.isLength(value, VIDEO_BLACKLIST_CONSTRAINTS_FIELDS.REASON)
}
function isVideoBlacklistTypeValid (value: any) {
return exists(value) && validator.isInt('' + value) && VideoBlacklistType[value] !== undefined
}
2018-08-13 16:57:13 +02:00
// ---------------------------------------------------------------------------
export {
isVideoBlacklistReasonValid,
2019-07-23 10:40:39 +02:00
isVideoBlacklistTypeValid
2018-08-13 16:57:13 +02:00
}