aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-16 09:28:18 +0200
committerChocobozzz <me@florianbigard.com>2018-05-16 09:42:56 +0200
commit2efd32f697549c59337db5177a93749af8e605d8 (patch)
tree42adaa4bb67b6aa48dcd4fb660616fb37b611573 /server/middlewares/validators
parent17c49e60b367868c80f44b9921793dc3a2d9adaa (diff)
downloadPeerTube-2efd32f697549c59337db5177a93749af8e605d8.tar.gz
PeerTube-2efd32f697549c59337db5177a93749af8e605d8.tar.zst
PeerTube-2efd32f697549c59337db5177a93749af8e605d8.zip
Fix updating video tags to empty field
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/videos.ts16
1 files changed, 9 insertions, 7 deletions
diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts
index aa2afb068..dd0246a63 100644
--- a/server/middlewares/validators/videos.ts
+++ b/server/middlewares/validators/videos.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import 'express-validator' 2import 'express-validator'
3import { body, param, query } from 'express-validator/check' 3import { body, param, query } from 'express-validator/check'
4import { UserRight, VideoPrivacy } from '../../../shared' 4import { UserRight, VideoPrivacy } from '../../../shared'
5import { isBooleanValid, isIdOrUUIDValid, isIdValid, isUUIDValid, toIntOrNull, toStringOrNull } from '../../helpers/custom-validators/misc' 5import { isBooleanValid, isIdOrUUIDValid, isIdValid, isUUIDValid, toIntOrNull, toValueOrNull } from '../../helpers/custom-validators/misc'
6import { 6import {
7 isVideoAbuseReasonValid, 7 isVideoAbuseReasonValid,
8 isVideoCategoryValid, 8 isVideoCategoryValid,
@@ -52,21 +52,22 @@ const videosAddValidator = [
52 .custom(isVideoLicenceValid).withMessage('Should have a valid licence'), 52 .custom(isVideoLicenceValid).withMessage('Should have a valid licence'),
53 body('language') 53 body('language')
54 .optional() 54 .optional()
55 .customSanitizer(toStringOrNull) 55 .customSanitizer(toValueOrNull)
56 .custom(isVideoLanguageValid).withMessage('Should have a valid language'), 56 .custom(isVideoLanguageValid).withMessage('Should have a valid language'),
57 body('nsfw') 57 body('nsfw')
58 .toBoolean() 58 .toBoolean()
59 .custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'), 59 .custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'),
60 body('description') 60 body('description')
61 .optional() 61 .optional()
62 .customSanitizer(toStringOrNull) 62 .customSanitizer(toValueOrNull)
63 .custom(isVideoDescriptionValid).withMessage('Should have a valid description'), 63 .custom(isVideoDescriptionValid).withMessage('Should have a valid description'),
64 body('support') 64 body('support')
65 .optional() 65 .optional()
66 .customSanitizer(toStringOrNull) 66 .customSanitizer(toValueOrNull)
67 .custom(isVideoSupportValid).withMessage('Should have a valid support text'), 67 .custom(isVideoSupportValid).withMessage('Should have a valid support text'),
68 body('tags') 68 body('tags')
69 .optional() 69 .optional()
70 .customSanitizer(toValueOrNull)
70 .custom(isVideoTagsValid).withMessage('Should have correct tags'), 71 .custom(isVideoTagsValid).withMessage('Should have correct tags'),
71 body('commentsEnabled') 72 body('commentsEnabled')
72 .toBoolean() 73 .toBoolean()
@@ -142,7 +143,7 @@ const videosUpdateValidator = [
142 .custom(isVideoLicenceValid).withMessage('Should have a valid licence'), 143 .custom(isVideoLicenceValid).withMessage('Should have a valid licence'),
143 body('language') 144 body('language')
144 .optional() 145 .optional()
145 .customSanitizer(toStringOrNull) 146 .customSanitizer(toValueOrNull)
146 .custom(isVideoLanguageValid).withMessage('Should have a valid language'), 147 .custom(isVideoLanguageValid).withMessage('Should have a valid language'),
147 body('nsfw') 148 body('nsfw')
148 .optional() 149 .optional()
@@ -154,14 +155,15 @@ const videosUpdateValidator = [
154 .custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'), 155 .custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'),
155 body('description') 156 body('description')
156 .optional() 157 .optional()
157 .customSanitizer(toStringOrNull) 158 .customSanitizer(toValueOrNull)
158 .custom(isVideoDescriptionValid).withMessage('Should have a valid description'), 159 .custom(isVideoDescriptionValid).withMessage('Should have a valid description'),
159 body('support') 160 body('support')
160 .optional() 161 .optional()
161 .customSanitizer(toStringOrNull) 162 .customSanitizer(toValueOrNull)
162 .custom(isVideoSupportValid).withMessage('Should have a valid support text'), 163 .custom(isVideoSupportValid).withMessage('Should have a valid support text'),
163 body('tags') 164 body('tags')
164 .optional() 165 .optional()
166 .customSanitizer(toValueOrNull)
165 .custom(isVideoTagsValid).withMessage('Should have correct tags'), 167 .custom(isVideoTagsValid).withMessage('Should have correct tags'),
166 body('commentsEnabled') 168 body('commentsEnabled')
167 .optional() 169 .optional()