]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/custom-validators/video-abuses.ts
Update validator dependency
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / video-abuses.ts
CommitLineData
268eebed 1import { Response } from 'express'
7cde3b9c 2import validator from 'validator'
74dc3bca 3import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants'
268eebed
C
4import { exists } from './misc'
5import { VideoAbuseModel } from '../../models/video/video-abuse'
6
7const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
8
9function isVideoAbuseReasonValid (value: string) {
10 return exists(value) && validator.isLength(value, VIDEO_ABUSES_CONSTRAINTS_FIELDS.REASON)
11}
12
13function isVideoAbuseModerationCommentValid (value: string) {
14 return exists(value) && validator.isLength(value, VIDEO_ABUSES_CONSTRAINTS_FIELDS.MODERATION_COMMENT)
15}
16
17function isVideoAbuseStateValid (value: string) {
18 return exists(value) && VIDEO_ABUSE_STATES[ value ] !== undefined
19}
20
268eebed
C
21// ---------------------------------------------------------------------------
22
23export {
268eebed
C
24 isVideoAbuseStateValid,
25 isVideoAbuseReasonValid,
26 isVideoAbuseModerationCommentValid
27}