1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Fix backend channel name validator consistency

This commit is contained in:
Chocobozzz 2021-08-05 13:54:35 +02:00
parent 352819ef92
commit 27db78400c
No known key found for this signature in database
GPG key ID: 583A612D890159BE
5 changed files with 29 additions and 22 deletions

View file

@ -1,14 +1,20 @@
import validator from 'validator'
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
import { exists } from './misc'
import { isUserUsernameValid } from './users'
const VIDEO_CHANNELS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_CHANNELS
function isVideoChannelUsernameValid (value: string) {
// Use the same constraints than user username
return isUserUsernameValid(value)
}
function isVideoChannelDescriptionValid (value: string) {
return value === null || validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.DESCRIPTION)
}
function isVideoChannelNameValid (value: string) {
function isVideoChannelDisplayNameValid (value: string) {
return exists(value) && validator.isLength(value, VIDEO_CHANNELS_CONSTRAINTS_FIELDS.NAME)
}
@ -19,7 +25,8 @@ function isVideoChannelSupportValid (value: string) {
// ---------------------------------------------------------------------------
export {
isVideoChannelUsernameValid,
isVideoChannelDescriptionValid,
isVideoChannelNameValid,
isVideoChannelDisplayNameValid,
isVideoChannelSupportValid
}