]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/helpers/custom-validators/video-abuses.ts
Merge branch 'release/2.1.0' into develop
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / video-abuses.ts
... / ...
CommitLineData
1import validator from 'validator'
2import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants'
3import { exists } from './misc'
4
5const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
6
7function isVideoAbuseReasonValid (value: string) {
8 return exists(value) && validator.isLength(value, VIDEO_ABUSES_CONSTRAINTS_FIELDS.REASON)
9}
10
11function isVideoAbuseModerationCommentValid (value: string) {
12 return exists(value) && validator.isLength(value, VIDEO_ABUSES_CONSTRAINTS_FIELDS.MODERATION_COMMENT)
13}
14
15function isVideoAbuseStateValid (value: string) {
16 return exists(value) && VIDEO_ABUSE_STATES[value] !== undefined
17}
18
19// ---------------------------------------------------------------------------
20
21export {
22 isVideoAbuseStateValid,
23 isVideoAbuseReasonValid,
24 isVideoAbuseModerationCommentValid
25}