X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fusers.ts;h=c56ae14ef81d7d89d6904fce26aab9f2b65ce861;hb=d5c8932a601c1854db0a2e399ccaf26e17385f1a;hp=1cb5e5b0f514a3d93efe669113ddbe1aadcabeb9;hpb=be0f59b4eec3c2c4dcd151e2b174be39dff1568e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 1cb5e5b0f..c56ae14ef 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts @@ -1,8 +1,7 @@ -import 'express-validator' import * as validator from 'validator' import { UserRole } from '../../../shared' -import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers' -import { exists, isFileValid, isBooleanValid } from './misc' +import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants' +import { exists, isArray, isBooleanValid, isFileValid } from './misc' import { values } from 'lodash' const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS @@ -46,10 +45,22 @@ function isUserWebTorrentEnabledValid (value: any) { return isBooleanValid(value) } +function isUserVideosHistoryEnabledValid (value: any) { + return isBooleanValid(value) +} + 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) +} + function isUserBlockedValid (value: any) { return isBooleanValid(value) } @@ -73,13 +84,16 @@ function isAvatarFile (files: { [ fieldname: string ]: Express.Multer.File[] } | // --------------------------------------------------------------------------- export { + isUserVideosHistoryEnabledValid, isUserBlockedValid, isUserPasswordValid, + isUserVideoLanguages, isUserBlockedReasonValid, isUserRoleValid, isUserVideoQuotaValid, isUserVideoQuotaDailyValid, isUserUsernameValid, + isUserAdminFlagsValid, isUserEmailVerifiedValid, isUserNSFWPolicyValid, isUserWebTorrentEnabledValid,