aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-08-17 15:36:03 +0200
committerChocobozzz <me@florianbigard.com>2022-08-17 15:36:03 +0200
commit690bb8f9f3413147a4f71d5ff0a3cd8170a94ce3 (patch)
treeb16b8536acd2098aba8c1d6fe13a336dd6aa01a9 /server/helpers
parentbbd5aa7ead5f1554a0872963f957effc26d8c630 (diff)
downloadPeerTube-690bb8f9f3413147a4f71d5ff0a3cd8170a94ce3.tar.gz
PeerTube-690bb8f9f3413147a4f71d5ff0a3cd8170a94ce3.tar.zst
PeerTube-690bb8f9f3413147a4f71d5ff0a3cd8170a94ce3.zip
Prefer using Object.values
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/custom-validators/users.ts5
-rw-r--r--server/helpers/custom-validators/videos.ts4
2 files changed, 4 insertions, 5 deletions
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 @@
1import { values } from 'lodash'
2import validator from 'validator' 1import validator from 'validator'
3import { UserRole } from '@shared/models' 2import { UserRole } from '@shared/models'
4import { isEmailEnabled } from '../../initializers/config' 3import { isEmailEnabled } from '../../initializers/config'
@@ -44,9 +43,9 @@ function isUserEmailVerifiedValid (value: any) {
44 return isBooleanValid(value) 43 return isBooleanValid(value)
45} 44}
46 45
47const nsfwPolicies = values(NSFW_POLICY_TYPES) 46const nsfwPolicies = new Set(Object.values(NSFW_POLICY_TYPES))
48function isUserNSFWPolicyValid (value: any) { 47function isUserNSFWPolicyValid (value: any) {
49 return exists(value) && nsfwPolicies.includes(value) 48 return exists(value) && nsfwPolicies.has(value)
50} 49}
51 50
52function isUserP2PEnabledValid (value: any) { 51function 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 @@
1import { UploadFilesForCheck } from 'express' 1import { UploadFilesForCheck } from 'express'
2import { values } from 'lodash'
3import magnetUtil from 'magnet-uri' 2import magnetUtil from 'magnet-uri'
4import validator from 'validator' 3import validator from 'validator'
5import { VideoFilter, VideoInclude, VideoPrivacy, VideoRateType } from '@shared/models' 4import { VideoFilter, VideoInclude, VideoPrivacy, VideoRateType } from '@shared/models'
@@ -78,8 +77,9 @@ function isVideoViewsValid (value: string) {
78 return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.VIEWS) 77 return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.VIEWS)
79} 78}
80 79
80const ratingTypes = new Set(Object.values(VIDEO_RATE_TYPES))
81function isVideoRatingTypeValid (value: string) { 81function isVideoRatingTypeValid (value: string) {
82 return value === 'none' || values(VIDEO_RATE_TYPES).includes(value as VideoRateType) 82 return value === 'none' || ratingTypes.has(value as VideoRateType)
83} 83}
84 84
85function isVideoFileExtnameValid (value: string) { 85function isVideoFileExtnameValid (value: string) {