diff options
Diffstat (limited to 'client/src/app/shared/shared-forms/form-validators/video-playlist-validators.service.ts')
-rw-r--r-- | client/src/app/shared/shared-forms/form-validators/video-playlist-validators.service.ts | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/client/src/app/shared/shared-forms/form-validators/video-playlist-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-playlist-validators.service.ts deleted file mode 100644 index 3b45a40fd..000000000 --- a/client/src/app/shared/shared-forms/form-validators/video-playlist-validators.service.ts +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | import { Injectable } from '@angular/core' | ||
2 | import { AbstractControl, Validators } from '@angular/forms' | ||
3 | import { VideoPlaylistPrivacy } from '@shared/models' | ||
4 | import { BuildFormValidator } from './form-validator.service' | ||
5 | |||
6 | @Injectable() | ||
7 | export class VideoPlaylistValidatorsService { | ||
8 | readonly VIDEO_PLAYLIST_DISPLAY_NAME: BuildFormValidator | ||
9 | readonly VIDEO_PLAYLIST_PRIVACY: BuildFormValidator | ||
10 | readonly VIDEO_PLAYLIST_DESCRIPTION: BuildFormValidator | ||
11 | readonly VIDEO_PLAYLIST_CHANNEL_ID: BuildFormValidator | ||
12 | |||
13 | constructor () { | ||
14 | this.VIDEO_PLAYLIST_DISPLAY_NAME = { | ||
15 | VALIDATORS: [ | ||
16 | Validators.required, | ||
17 | Validators.minLength(1), | ||
18 | Validators.maxLength(120) | ||
19 | ], | ||
20 | MESSAGES: { | ||
21 | 'required': $localize`Display name is required.`, | ||
22 | 'minlength': $localize`Display name must be at least 1 character long.`, | ||
23 | 'maxlength': $localize`Display name cannot be more than 120 characters long.` | ||
24 | } | ||
25 | } | ||
26 | |||
27 | this.VIDEO_PLAYLIST_PRIVACY = { | ||
28 | VALIDATORS: [ | ||
29 | Validators.required | ||
30 | ], | ||
31 | MESSAGES: { | ||
32 | 'required': $localize`Privacy is required.` | ||
33 | } | ||
34 | } | ||
35 | |||
36 | this.VIDEO_PLAYLIST_DESCRIPTION = { | ||
37 | VALIDATORS: [ | ||
38 | Validators.minLength(3), | ||
39 | Validators.maxLength(1000) | ||
40 | ], | ||
41 | MESSAGES: { | ||
42 | 'minlength': $localize`Description must be at least 3 characters long.`, | ||
43 | 'maxlength': $localize`Description cannot be more than 1000 characters long.` | ||
44 | } | ||
45 | } | ||
46 | |||
47 | this.VIDEO_PLAYLIST_CHANNEL_ID = { | ||
48 | VALIDATORS: [ ], | ||
49 | MESSAGES: { | ||
50 | 'required': $localize`The channel is required when the playlist is public.` | ||
51 | } | ||
52 | } | ||
53 | } | ||
54 | |||
55 | setChannelValidator (channelControl: AbstractControl, privacy: VideoPlaylistPrivacy) { | ||
56 | if (privacy.toString() === VideoPlaylistPrivacy.PUBLIC.toString()) { | ||
57 | channelControl.setValidators([ Validators.required ]) | ||
58 | } else { | ||
59 | channelControl.setValidators(null) | ||
60 | } | ||
61 | |||
62 | channelControl.markAsDirty() | ||
63 | channelControl.updateValueAndValidity() | ||
64 | } | ||
65 | } | ||