diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-05 13:54:35 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-08-05 13:54:35 +0200 |
commit | 27db78400c558e19bfac0da885fe0b7d0a3e6a0c (patch) | |
tree | e50e031f4b0989e438f3c1610c0a16086dd9455f /server/helpers | |
parent | 352819ef921e45381b3fbb17072926103b320e73 (diff) | |
download | PeerTube-27db78400c558e19bfac0da885fe0b7d0a3e6a0c.tar.gz PeerTube-27db78400c558e19bfac0da885fe0b7d0a3e6a0c.tar.zst PeerTube-27db78400c558e19bfac0da885fe0b7d0a3e6a0c.zip |
Fix backend channel name validator consistency
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/video-channels.ts | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/server/helpers/custom-validators/video-channels.ts b/server/helpers/custom-validators/video-channels.ts index ded5d5171..249083f39 100644 --- a/server/helpers/custom-validators/video-channels.ts +++ b/server/helpers/custom-validators/video-channels.ts | |||
@@ -1,14 +1,20 @@ | |||
1 | import validator from 'validator' | 1 | import validator from 'validator' |
2 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | 2 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' |
3 | import { exists } from './misc' | 3 | import { exists } from './misc' |
4 | import { isUserUsernameValid } from './users' | ||
4 | 5 | ||
5 | const VIDEO_CHANNELS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_CHANNELS | 6 | const VIDEO_CHANNELS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_CHANNELS |
6 | 7 | ||
8 | function isVideoChannelUsernameValid (value: string) { | ||
9 | // Use the same constraints than user username | ||
10 | return isUserUsernameValid(value) | ||
11 | } | ||
12 | |||
7 | function isVideoChannelDescriptionValid (value: string) { | 13 | function isVideoChannelDescriptionValid (value: string) { |
8 | return value === null || validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.DESCRIPTION) | 14 | return value === null || validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.DESCRIPTION) |
9 | } | 15 | } |
10 | 16 | ||
11 | function isVideoChannelNameValid (value: string) { | 17 | function isVideoChannelDisplayNameValid (value: string) { |
12 | return exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.NAME) | 18 | return exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.NAME) |
13 | } | 19 | } |
14 | 20 | ||
@@ -19,7 +25,8 @@ function isVideoChannelSupportValid (value: string) { | |||
19 | // --------------------------------------------------------------------------- | 25 | // --------------------------------------------------------------------------- |
20 | 26 | ||
21 | export { | 27 | export { |
28 | isVideoChannelUsernameValid, | ||
22 | isVideoChannelDescriptionValid, | 29 | isVideoChannelDescriptionValid, |
23 | isVideoChannelNameValid, | 30 | isVideoChannelDisplayNameValid, |
24 | isVideoChannelSupportValid | 31 | isVideoChannelSupportValid |
25 | } | 32 | } |