aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/users.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators/users.ts')
-rw-r--r--server/helpers/custom-validators/users.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts
index 56bc10b16..738d5cbbf 100644
--- a/server/helpers/custom-validators/users.ts
+++ b/server/helpers/custom-validators/users.ts
@@ -2,7 +2,7 @@ import 'express-validator'
2import * as validator from 'validator' 2import * as validator from 'validator'
3import { UserRole } from '../../../shared' 3import { UserRole } from '../../../shared'
4import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants' 4import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants'
5import { exists, isBooleanValid, isFileValid } from './misc' 5import { exists, isArray, isBooleanValid, isFileValid } from './misc'
6import { values } from 'lodash' 6import { values } from 'lodash'
7 7
8const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS 8const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS
@@ -54,6 +54,10 @@ function isUserAutoPlayVideoValid (value: any) {
54 return isBooleanValid(value) 54 return isBooleanValid(value)
55} 55}
56 56
57function isUserVideoLanguages (value: any) {
58 return value === null || (isArray(value) && value.length < CONSTRAINTS_FIELDS.USERS.VIDEO_LANGUAGES.max)
59}
60
57function isUserAdminFlagsValid (value: any) { 61function isUserAdminFlagsValid (value: any) {
58 return exists(value) && validator.isInt('' + value) 62 return exists(value) && validator.isInt('' + value)
59} 63}
@@ -84,6 +88,7 @@ export {
84 isUserVideosHistoryEnabledValid, 88 isUserVideosHistoryEnabledValid,
85 isUserBlockedValid, 89 isUserBlockedValid,
86 isUserPasswordValid, 90 isUserPasswordValid,
91 isUserVideoLanguages,
87 isUserBlockedReasonValid, 92 isUserBlockedReasonValid,
88 isUserRoleValid, 93 isUserRoleValid,
89 isUserVideoQuotaValid, 94 isUserVideoQuotaValid,