aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorRamiellll <ramyyy.ramiel@gmail.com>2021-02-23 22:16:35 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-02-25 09:55:34 +0100
commitb58a894bc9cb0c02fb61efd00415dcf433b83567 (patch)
tree41fca554277f61517eb27406c1e2fb951a240ca3 /client/src/app
parente072fb1e1633e57c986b2d19646b7a140af03bb8 (diff)
downloadPeerTube-b58a894bc9cb0c02fb61efd00415dcf433b83567.tar.gz
PeerTube-b58a894bc9cb0c02fb61efd00415dcf433b83567.tar.zst
PeerTube-b58a894bc9cb0c02fb61efd00415dcf433b83567.zip
Fix titles do not trim leading and trailing spaces
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/shared/form-validators/video-validators.ts16
1 files changed, 13 insertions, 3 deletions
diff --git a/client/src/app/shared/form-validators/video-validators.ts b/client/src/app/shared/form-validators/video-validators.ts
index b3ce876b1..0000f18ba 100644
--- a/client/src/app/shared/form-validators/video-validators.ts
+++ b/client/src/app/shared/form-validators/video-validators.ts
@@ -1,12 +1,22 @@
1import { AbstractControl, ValidationErrors, ValidatorFn, Validators } from '@angular/forms' 1import { AbstractControl, ValidationErrors, ValidatorFn, Validators, FormControl } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model' 2import { BuildFormValidator } from './form-validator.model'
3 3
4export const trimValidator: ValidatorFn = (control: FormControl) => {
5 if (control.value.startsWith(' ') || control.value.endsWith(' ')) {
6 return {
7 'spaces': true
8 }
9 }
10 return null;
11};
12
4export const VIDEO_NAME_VALIDATOR: BuildFormValidator = { 13export const VIDEO_NAME_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ], 14 VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120), trimValidator ],
6 MESSAGES: { 15 MESSAGES: {
7 'required': $localize`Video name is required.`, 16 'required': $localize`Video name is required.`,
8 'minlength': $localize`Video name must be at least 3 characters long.`, 17 'minlength': $localize`Video name must be at least 3 characters long.`,
9 'maxlength': $localize`Video name cannot be more than 120 characters long.` 18 'maxlength': $localize`Video name cannot be more than 120 characters long.`,
19 'spaces': $localize`Video name has leading or trailing whitespace.`
10 } 20 }
11} 21}
12 22