aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/users.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-06-19 14:55:58 +0200
committerChocobozzz <me@florianbigard.com>2019-06-19 15:05:36 +0200
commit3caf77d3b11f2dbc12e52d665183d36604c1dab9 (patch)
tree53e08727d5f1dc8be2bd4f4a14dadc05f607a9fb /server/helpers/custom-validators/users.ts
parentbbe078ba55be635b5fc92f8f6286c45792b9e7e5 (diff)
downloadPeerTube-3caf77d3b11f2dbc12e52d665183d36604c1dab9.tar.gz
PeerTube-3caf77d3b11f2dbc12e52d665183d36604c1dab9.tar.zst
PeerTube-3caf77d3b11f2dbc12e52d665183d36604c1dab9.zip
Add language filters in user preferences
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,