]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/custom-validators/video-channels.ts
emit more specific status codes on video upload (#3423)
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / video-channels.ts
CommitLineData
7cde3b9c 1import validator from 'validator'
74dc3bca 2import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
4e50b6a1 3import { exists } from './misc'
72c7248b
C
4
5const VIDEO_CHANNELS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_CHANNELS
6
7function isVideoChannelDescriptionValid (value: string) {
8 return value === null || validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.DESCRIPTION)
9}
10
11function isVideoChannelNameValid (value: string) {
12 return exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.NAME)
13}
14
2422c46b
C
15function isVideoChannelSupportValid (value: string) {
16 return value === null || (exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.SUPPORT))
17}
18
72c7248b
C
19// ---------------------------------------------------------------------------
20
21export {
22 isVideoChannelDescriptionValid,
4e50b6a1 23 isVideoChannelNameValid,
5b77537c 24 isVideoChannelSupportValid
06a05d5f 25}