Validate video attribute "importedFrom"
This commit is contained in:
parent
b2e1f0783c
commit
4949040b1a
|
@ -13,6 +13,7 @@ import {
|
|||
VIDEO_LANGUAGE_VALIDATOR,
|
||||
VIDEO_LICENCE_VALIDATOR,
|
||||
VIDEO_NAME_VALIDATOR,
|
||||
VIDEO_IMPORTED_FROM_VALIDATOR,
|
||||
VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR,
|
||||
VIDEO_PRIVACY_VALIDATOR,
|
||||
VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR,
|
||||
|
@ -161,7 +162,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
|
|||
previewfile: null,
|
||||
support: VIDEO_SUPPORT_VALIDATOR,
|
||||
schedulePublicationAt: VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR,
|
||||
importedFrom: null,
|
||||
importedFrom: VIDEO_IMPORTED_FROM_VALIDATOR,
|
||||
originallyPublishedAt: VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR,
|
||||
liveStreamKey: null,
|
||||
permanentLive: null,
|
||||
|
|
|
@ -92,6 +92,14 @@ export const VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR: BuildFormValidator = {
|
|||
}
|
||||
}
|
||||
|
||||
export const VIDEO_IMPORTED_FROM_VALIDATOR: BuildFormValidator = {
|
||||
VALIDATORS: [ Validators.minLength(3), Validators.maxLength(2000) ],
|
||||
MESSAGES: {
|
||||
minlength: $localize`Video import URL must be at least 3 characters long.`,
|
||||
maxlength: $localize`Video import URL cannot be more than 120 characters long.`
|
||||
}
|
||||
}
|
||||
|
||||
export const VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR: BuildFormValidator = {
|
||||
VALIDATORS: [ ],
|
||||
MESSAGES: {}
|
||||
|
|
|
@ -114,6 +114,12 @@ function isScheduleVideoUpdatePrivacyValid (value: number) {
|
|||
return value === VideoPrivacy.UNLISTED || value === VideoPrivacy.PUBLIC || value === VideoPrivacy.INTERNAL
|
||||
}
|
||||
|
||||
function isVideoImportedFromValid (value: string | null) {
|
||||
return value === null ||
|
||||
(typeof value === 'string' &&
|
||||
validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.IMPORTED_FROM))
|
||||
}
|
||||
|
||||
function isVideoOriginallyPublishedAtValid (value: string | null) {
|
||||
return value === null || isDateValid(value)
|
||||
}
|
||||
|
@ -153,6 +159,7 @@ export {
|
|||
areVideoTagsValid,
|
||||
isVideoFPSResolutionValid,
|
||||
isScheduleVideoUpdatePrivacyValid,
|
||||
isVideoImportedFromValid,
|
||||
isVideoOriginallyPublishedAtValid,
|
||||
isVideoMagnetUriValid,
|
||||
isVideoStateValid,
|
||||
|
|
|
@ -356,7 +356,8 @@ const CONSTRAINTS_FIELDS = {
|
|||
DISLIKES: { min: 0 },
|
||||
FILE_SIZE: { min: -1 },
|
||||
PARTIAL_UPLOAD_SIZE: { max: 50 * 1024 * 1024 * 1024 }, // 50GB
|
||||
URL: { min: 3, max: 2000 } // Length
|
||||
URL: { min: 3, max: 2000 }, // Length
|
||||
IMPORTED_FROM: { min: 3, max: 2000 } // Length
|
||||
},
|
||||
VIDEO_PLAYLISTS: {
|
||||
NAME: { min: 1, max: 120 }, // Length
|
||||
|
|
|
@ -32,6 +32,7 @@ import {
|
|||
isVideoLanguageValid,
|
||||
isVideoLicenceValid,
|
||||
isVideoNameValid,
|
||||
isVideoImportedFromValid,
|
||||
isVideoOriginallyPublishedAtValid,
|
||||
isVideoPrivacyValid,
|
||||
isVideoSupportValid
|
||||
|
@ -415,6 +416,10 @@ function getCommonVideoEditAttributes () {
|
|||
.optional()
|
||||
.customSanitizer(toBooleanOrNull)
|
||||
.custom(isBooleanValid).withMessage('Should have downloadEnabled boolean'),
|
||||
body('importedFrom')
|
||||
.optional()
|
||||
.customSanitizer(toValueOrNull)
|
||||
.custom(isVideoImportedFromValid),
|
||||
body('originallyPublishedAt')
|
||||
.optional()
|
||||
.customSanitizer(toValueOrNull)
|
||||
|
|
Loading…
Reference in New Issue