X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fvideos.ts;h=9e8177f77a58f001eb4dcb529285fe58695a49ae;hb=f713f36bdf6f696ab0fe8a309035a09e864a48ca;hp=ca5f70fdc2e8574dc52c7a5207afc14fe039eb74;hpb=ab4b8974997777373a6032073f9c1aaf33ba9931;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index ca5f70fdc..9e8177f77 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -1,5 +1,4 @@ import { UploadFilesForCheck } from 'express' -import { values } from 'lodash' import magnetUtil from 'magnet-uri' import validator from 'validator' import { VideoFilter, VideoInclude, VideoPrivacy, VideoRateType } from '@shared/models' @@ -46,10 +45,6 @@ function isVideoDurationValid (value: string) { return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.DURATION) } -function isVideoTruncatedDescriptionValid (value: string) { - return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.TRUNCATED_DESCRIPTION) -} - function isVideoDescriptionValid (value: string) { return value === null || (exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION)) } @@ -78,8 +73,9 @@ function isVideoViewsValid (value: string) { return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.VIEWS) } +const ratingTypes = new Set(Object.values(VIDEO_RATE_TYPES)) function isVideoRatingTypeValid (value: string) { - return value === 'none' || values(VIDEO_RATE_TYPES).includes(value as VideoRateType) + return value === 'none' || ratingTypes.has(value as VideoRateType) } function isVideoFileExtnameValid (value: string) { @@ -151,7 +147,6 @@ export { isVideoCategoryValid, isVideoLicenceValid, isVideoLanguageValid, - isVideoTruncatedDescriptionValid, isVideoDescriptionValid, isVideoFileInfoHashValid, isVideoNameValid,