aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-16 10:36:18 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-16 10:36:18 +0200
commitee9e7b61f59a427208386738057c8eff48fba599 (patch)
tree9097de886128e15f21f0b5920a2076d16a087467 /server/helpers/custom-validators
parent70c065d64c330196d371941d9294a55da6e3aa37 (diff)
downloadPeerTube-ee9e7b61f59a427208386738057c8eff48fba599.tar.gz
PeerTube-ee9e7b61f59a427208386738057c8eff48fba599.tar.zst
PeerTube-ee9e7b61f59a427208386738057c8eff48fba599.zip
Create types for model enums
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/users.ts4
-rw-r--r--server/helpers/custom-validators/videos.ts3
2 files changed, 5 insertions, 2 deletions
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts
index 7792ffd74..750563ada 100644
--- a/server/helpers/custom-validators/users.ts
+++ b/server/helpers/custom-validators/users.ts
@@ -3,6 +3,8 @@ import * as validator from 'validator'
3 3
4import { exists } from './misc' 4import { exists } from './misc'
5import { CONSTRAINTS_FIELDS, USER_ROLES } from '../../initializers' 5import { CONSTRAINTS_FIELDS, USER_ROLES } from '../../initializers'
6import { UserRole } from '../../../shared'
7
6const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS 8const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS
7 9
8function isUserPasswordValid (value: string) { 10function isUserPasswordValid (value: string) {
@@ -10,7 +12,7 @@ function isUserPasswordValid (value: string) {
10} 12}
11 13
12function isUserRoleValid (value: string) { 14function isUserRoleValid (value: string) {
13 return values(USER_ROLES).indexOf(value) !== -1 15 return values(USER_ROLES).indexOf(value as UserRole) !== -1
14} 16}
15 17
16function isUserUsernameValid (value: string) { 18function isUserUsernameValid (value: string) {
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index 8904975c0..72d226e81 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -11,6 +11,7 @@ import {
11} from '../../initializers' 11} from '../../initializers'
12import { isUserUsernameValid } from './users' 12import { isUserUsernameValid } from './users'
13import { isArray, exists } from './misc' 13import { isArray, exists } from './misc'
14import { VideoRateType } from '../../../shared'
14 15
15const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS 16const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
16const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES 17const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES
@@ -105,7 +106,7 @@ function isVideoEventCountValid (value: string) {
105} 106}
106 107
107function isVideoRatingTypeValid (value: string) { 108function isVideoRatingTypeValid (value: string) {
108 return values(VIDEO_RATE_TYPES).indexOf(value) !== -1 109 return values(VIDEO_RATE_TYPES).indexOf(value as VideoRateType) !== -1
109} 110}
110 111
111function isVideoFile (value: string, files: { [ fieldname: string ]: Express.Multer.File[] }) { 112function isVideoFile (value: string, files: { [ fieldname: string ]: Express.Multer.File[] }) {