X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fusers.ts;h=c56ae14ef81d7d89d6904fce26aab9f2b65ce861;hb=d5c8932a601c1854db0a2e399ccaf26e17385f1a;hp=e3ad9102ad030911f6ef5551f5081dce9d1aeeed;hpb=1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index e3ad9102a..c56ae14ef 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts @@ -1,10 +1,8 @@ -import 'express-validator' import * as validator from 'validator' -import { UserNotificationSettingValue, UserRole } from '../../../shared' +import { UserRole } from '../../../shared' import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants' -import { exists, isFileValid, isBooleanValid } from './misc' +import { exists, isArray, isBooleanValid, isFileValid } from './misc' import { values } from 'lodash' -import { UserAdminFlag } from '../../../shared/models/users/user-flag.model' const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS @@ -55,6 +53,10 @@ function isUserAutoPlayVideoValid (value: any) { return isBooleanValid(value) } +function isUserVideoLanguages (value: any) { + return value === null || (isArray(value) && value.length < CONSTRAINTS_FIELDS.USERS.VIDEO_LANGUAGES.max) +} + function isUserAdminFlagsValid (value: any) { return exists(value) && validator.isInt('' + value) } @@ -85,6 +87,7 @@ export { isUserVideosHistoryEnabledValid, isUserBlockedValid, isUserPasswordValid, + isUserVideoLanguages, isUserBlockedReasonValid, isUserRoleValid, isUserVideoQuotaValid,