1 import validator from 'validator'
2 import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
3 import { exists } from './misc'
4 import { isUserUsernameValid } from './users'
6 const VIDEO_CHANNELS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_CHANNELS
8 function isVideoChannelUsernameValid (value: string) {
9 // Use the same constraints than user username
10 return isUserUsernameValid(value)
13 function isVideoChannelDescriptionValid (value: string) {
14 return value === null || validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.DESCRIPTION)
17 function isVideoChannelDisplayNameValid (value: string) {
18 return exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.NAME)
21 function isVideoChannelSupportValid (value: string) {
22 return value === null || (exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.SUPPORT))
25 // ---------------------------------------------------------------------------
28 isVideoChannelUsernameValid,
29 isVideoChannelDescriptionValid,
30 isVideoChannelDisplayNameValid,
31 isVideoChannelSupportValid