]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/helpers/custom-validators/video-channels.ts
Add hooks documentation
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / video-channels.ts
1 import 'express-validator'
2 import 'multer'
3 import * as validator from 'validator'
4 import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
5 import { exists } from './misc'
6
7 const VIDEO_CHANNELS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_CHANNELS
8
9 function isVideoChannelDescriptionValid (value: string) {
10 return value === null || validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.DESCRIPTION)
11 }
12
13 function isVideoChannelNameValid (value: string) {
14 return exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.NAME)
15 }
16
17 function isVideoChannelSupportValid (value: string) {
18 return value === null || (exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.SUPPORT))
19 }
20
21 // ---------------------------------------------------------------------------
22
23 export {
24 isVideoChannelDescriptionValid,
25 isVideoChannelNameValid,
26 isVideoChannelSupportValid
27 }