]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/helpers/custom-validators/video-channels.ts
Accept numbers in plugin names
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / video-channels.ts
... / ...
CommitLineData
1import validator from 'validator'
2import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
3import { exists } from './misc'
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
15function isVideoChannelSupportValid (value: string) {
16 return value === null || (exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.SUPPORT))
17}
18
19// ---------------------------------------------------------------------------
20
21export {
22 isVideoChannelDescriptionValid,
23 isVideoChannelNameValid,
24 isVideoChannelSupportValid
25}