Trim video name also on server
This commit is contained in:
parent
56b0a516f2
commit
0221f8c9b1
2 changed files with 7 additions and 6 deletions
|
@ -3,15 +3,14 @@ import { BuildFormValidator } from './form-validator.model'
|
|||
|
||||
export const trimValidator: ValidatorFn = (control: FormControl) => {
|
||||
if (control.value.startsWith(' ') || control.value.endsWith(' ')) {
|
||||
return {
|
||||
'spaces': true
|
||||
}
|
||||
return { spaces: true }
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export const VIDEO_NAME_VALIDATOR: BuildFormValidator = {
|
||||
VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120), trimValidator ],
|
||||
VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ],
|
||||
MESSAGES: {
|
||||
'required': $localize`Video name is required.`,
|
||||
'minlength': $localize`Video name must be at least 3 characters long.`,
|
||||
|
|
|
@ -62,6 +62,7 @@ const videosAddValidator = getCommonVideoEditAttributes().concat([
|
|||
.custom((value, { req }) => isFileFieldValid(req.files, 'videofile'))
|
||||
.withMessage('Should have a file'),
|
||||
body('name')
|
||||
.trim()
|
||||
.custom(isVideoNameValid)
|
||||
.withMessage('Should have a valid name'),
|
||||
body('channelId')
|
||||
|
@ -129,6 +130,7 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([
|
|||
param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
|
||||
body('name')
|
||||
.optional()
|
||||
.trim()
|
||||
.custom(isVideoNameValid).withMessage('Should have a valid name'),
|
||||
body('channelId')
|
||||
.optional()
|
||||
|
|
Loading…
Reference in a new issue