]>
Commit | Line | Data |
---|---|---|
7cde3b9c | 1 | import validator from 'validator' |
74dc3bca | 2 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' |
4e50b6a1 | 3 | import { exists } from './misc' |
27db7840 | 4 | import { isUserUsernameValid } from './users' |
72c7248b C |
5 | |
6 | const VIDEO_CHANNELS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_CHANNELS | |
7 | ||
27db7840 C |
8 | function isVideoChannelUsernameValid (value: string) { |
9 | // Use the same constraints than user username | |
10 | return isUserUsernameValid(value) | |
11 | } | |
12 | ||
72c7248b C |
13 | function isVideoChannelDescriptionValid (value: string) { |
14 | return value === null || validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.DESCRIPTION) | |
15 | } | |
16 | ||
27db7840 | 17 | function isVideoChannelDisplayNameValid (value: string) { |
72c7248b C |
18 | return exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.NAME) |
19 | } | |
20 | ||
2422c46b C |
21 | function isVideoChannelSupportValid (value: string) { |
22 | return value === null || (exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.SUPPORT)) | |
23 | } | |
24 | ||
72c7248b C |
25 | // --------------------------------------------------------------------------- |
26 | ||
27 | export { | |
27db7840 | 28 | isVideoChannelUsernameValid, |
72c7248b | 29 | isVideoChannelDescriptionValid, |
27db7840 | 30 | isVideoChannelDisplayNameValid, |
5b77537c | 31 | isVideoChannelSupportValid |
06a05d5f | 32 | } |