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