Add action hooks to user routes
[oweals/peertube.git] / server / helpers / custom-validators / video-abuses.ts
1 import { Response } from 'express'
2 import * as validator from 'validator'
3 import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants'
4 import { exists } from './misc'
5 import { VideoAbuseModel } from '../../models/video/video-abuse'
6
7 const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
8
9 function isVideoAbuseReasonValid (value: string) {
10   return exists(value) && validator.isLength(value, VIDEO_ABUSES_CONSTRAINTS_FIELDS.REASON)
11 }
12
13 function isVideoAbuseModerationCommentValid (value: string) {
14   return exists(value) && validator.isLength(value, VIDEO_ABUSES_CONSTRAINTS_FIELDS.MODERATION_COMMENT)
15 }
16
17 function isVideoAbuseStateValid (value: string) {
18   return exists(value) && VIDEO_ABUSE_STATES[ value ] !== undefined
19 }
20
21 // ---------------------------------------------------------------------------
22
23 export {
24   isVideoAbuseStateValid,
25   isVideoAbuseReasonValid,
26   isVideoAbuseModerationCommentValid
27 }