diff options
Diffstat (limited to 'client/src/app')
-rw-r--r-- | client/src/app/shared/form-validators/video-validators.ts | 16 |
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 @@ | |||
1 | import { AbstractControl, ValidationErrors, ValidatorFn, Validators } from '@angular/forms' | 1 | import { AbstractControl, ValidationErrors, ValidatorFn, Validators, FormControl } from '@angular/forms' |
2 | import { BuildFormValidator } from './form-validator.model' | 2 | import { BuildFormValidator } from './form-validator.model' |
3 | 3 | ||
4 | export 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 | |||
4 | export const VIDEO_NAME_VALIDATOR: BuildFormValidator = { | 13 | export 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 | ||