]>
Commit | Line | Data |
---|---|---|
e309822b C |
1 | import { I18n } from '@ngx-translate/i18n-polyfill' |
2 | import { Validators } from '@angular/forms' | |
3 | import { Injectable } from '@angular/core' | |
4 | import { BuildFormValidator } from '@app/shared' | |
5 | ||
6 | @Injectable() | |
7 | export class VideoValidatorsService { | |
8 | readonly VIDEO_NAME: BuildFormValidator | |
9 | readonly VIDEO_PRIVACY: BuildFormValidator | |
10 | readonly VIDEO_CATEGORY: BuildFormValidator | |
11 | readonly VIDEO_LICENCE: BuildFormValidator | |
12 | readonly VIDEO_LANGUAGE: BuildFormValidator | |
13 | readonly VIDEO_IMAGE: BuildFormValidator | |
14 | readonly VIDEO_CHANNEL: BuildFormValidator | |
15 | readonly VIDEO_DESCRIPTION: BuildFormValidator | |
16 | readonly VIDEO_TAGS: BuildFormValidator | |
17 | readonly VIDEO_SUPPORT: BuildFormValidator | |
bbe0f064 | 18 | readonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator |
1e74f19a | 19 | readonly VIDEO_ORIGINALLY_PUBLISHED_AT: BuildFormValidator |
e309822b C |
20 | |
21 | constructor (private i18n: I18n) { | |
22 | ||
23 | this.VIDEO_NAME = { | |
24 | VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ], | |
25 | MESSAGES: { | |
26 | 'required': this.i18n('Video name is required.'), | |
27 | 'minlength': this.i18n('Video name must be at least 3 characters long.'), | |
28 | 'maxlength': this.i18n('Video name cannot be more than 120 characters long.') | |
29 | } | |
30 | } | |
31 | ||
32 | this.VIDEO_PRIVACY = { | |
33 | VALIDATORS: [ Validators.required ], | |
34 | MESSAGES: { | |
35 | 'required': this.i18n('Video privacy is required.') | |
36 | } | |
37 | } | |
38 | ||
39 | this.VIDEO_CATEGORY = { | |
40 | VALIDATORS: [ ], | |
41 | MESSAGES: {} | |
42 | } | |
43 | ||
44 | this.VIDEO_LICENCE = { | |
45 | VALIDATORS: [ ], | |
46 | MESSAGES: {} | |
47 | } | |
48 | ||
49 | this.VIDEO_LANGUAGE = { | |
50 | VALIDATORS: [ ], | |
51 | MESSAGES: {} | |
52 | } | |
53 | ||
54 | this.VIDEO_IMAGE = { | |
55 | VALIDATORS: [ ], | |
56 | MESSAGES: {} | |
57 | } | |
58 | ||
59 | this.VIDEO_CHANNEL = { | |
60 | VALIDATORS: [ Validators.required ], | |
61 | MESSAGES: { | |
62 | 'required': this.i18n('Video channel is required.') | |
63 | } | |
64 | } | |
65 | ||
66 | this.VIDEO_DESCRIPTION = { | |
67 | VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ], | |
68 | MESSAGES: { | |
69 | 'minlength': this.i18n('Video description must be at least 3 characters long.'), | |
70 | 'maxlength': this.i18n('Video description cannot be more than 10000 characters long.') | |
71 | } | |
72 | } | |
73 | ||
74 | this.VIDEO_TAGS = { | |
75 | VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ], | |
76 | MESSAGES: { | |
77 | 'minlength': this.i18n('A tag should be more than 2 characters long.'), | |
78 | 'maxlength': this.i18n('A tag should be less than 30 characters long.') | |
79 | } | |
80 | } | |
81 | ||
82 | this.VIDEO_SUPPORT = { | |
d23e6a1c | 83 | VALIDATORS: [ Validators.minLength(3), Validators.maxLength(1000) ], |
e309822b C |
84 | MESSAGES: { |
85 | 'minlength': this.i18n('Video support must be at least 3 characters long.'), | |
d23e6a1c | 86 | 'maxlength': this.i18n('Video support cannot be more than 1000 characters long.') |
e309822b C |
87 | } |
88 | } | |
bbe0f064 C |
89 | |
90 | this.VIDEO_SCHEDULE_PUBLICATION_AT = { | |
91 | VALIDATORS: [ ], | |
92 | MESSAGES: { | |
93 | 'required': this.i18n('A date is required to schedule video update.') | |
94 | } | |
95 | } | |
1e74f19a | 96 | |
97 | this.VIDEO_ORIGINALLY_PUBLISHED_AT = { | |
98 | VALIDATORS: [ ], | |
99 | MESSAGES: {} | |
100 | } | |
e309822b C |
101 | } |
102 | } |