Fix backend channel name validator consistency

This commit is contained in:
Chocobozzz committed 2021-08-05 13:54:35 +02:00
1 parent 352819ef92
commit 27db78400c
5 files changed
+29 -22

No files matched your search

@@ -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
}