From 690bb8f9f3413147a4f71d5ff0a3cd8170a94ce3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 17 Aug 2022 15:36:03 +0200 Subject: Prefer using Object.values --- server/helpers/custom-validators/users.ts | 5 ++--- server/helpers/custom-validators/videos.ts | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'server/helpers/custom-validators') diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 8a6f6fca1..9df550fc2 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts @@ -1,4 +1,3 @@ -import { values } from 'lodash' import validator from 'validator' import { UserRole } from '@shared/models' import { isEmailEnabled } from '../../initializers/config' @@ -44,9 +43,9 @@ function isUserEmailVerifiedValid (value: any) { return isBooleanValid(value) } -const nsfwPolicies = values(NSFW_POLICY_TYPES) +const nsfwPolicies = new Set(Object.values(NSFW_POLICY_TYPES)) function isUserNSFWPolicyValid (value: any) { - return exists(value) && nsfwPolicies.includes(value) + return exists(value) && nsfwPolicies.has(value) } function isUserP2PEnabledValid (value: any) { diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index ca5f70fdc..3ebfe2937 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' @@ -78,8 +77,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) { -- cgit v1.2.3