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

23 lines
758 B
TypeScript
Raw Normal View History

2020-01-07 07:56:07 -06:00
import validator from 'validator'
import { exists } from './misc'
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
import { VideoBlacklistType } from '../../../shared/models/videos'
2018-08-13 09:57:13 -05: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) {
2020-08-06 07:58:01 -05:00
return exists(value) &&
(value === VideoBlacklistType.AUTO_BEFORE_PUBLISHED || value === VideoBlacklistType.MANUAL)
}
2018-08-13 09:57:13 -05:00
// ---------------------------------------------------------------------------
export {
isVideoBlacklistReasonValid,
2019-07-23 03:40:39 -05:00
isVideoBlacklistTypeValid
2018-08-13 09:57:13 -05:00
}