]>
Commit | Line | Data |
---|---|---|
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 | |
18 | readonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator | |
19 | ||
20 | constructor (private i18n: I18n) { | |
21 | ||
22 | this.VIDEO_NAME = { | |
23 | VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ], | |
24 | MESSAGES: { | |
25 | 'required': this.i18n('Video name is required.'), | |
26 | 'minlength': this.i18n('Video name must be at least 3 characters long.'), | |
27 | 'maxlength': this.i18n('Video name cannot be more than 120 characters long.') | |
28 | } | |
29 | } | |
30 | ||
31 | this.VIDEO_PRIVACY = { | |
32 | VALIDATORS: [ Validators.required ], | |
33 | MESSAGES: { | |
34 | 'required': this.i18n('Video privacy is required.') | |
35 | } | |
36 | } | |
37 | ||
38 | this.VIDEO_CATEGORY = { | |
39 | VALIDATORS: [ ], | |
40 | MESSAGES: {} | |
41 | } | |
42 | ||
43 | this.VIDEO_LICENCE = { | |
44 | VALIDATORS: [ ], | |
45 | MESSAGES: {} | |
46 | } | |
47 | ||
48 | this.VIDEO_LANGUAGE = { | |
49 | VALIDATORS: [ ], | |
50 | MESSAGES: {} | |
51 | } | |
52 | ||
53 | this.VIDEO_IMAGE = { | |
54 | VALIDATORS: [ ], | |
55 | MESSAGES: {} | |
56 | } | |
57 | ||
58 | this.VIDEO_CHANNEL = { | |
59 | VALIDATORS: [ Validators.required ], | |
60 | MESSAGES: { | |
61 | 'required': this.i18n('Video channel is required.') | |
62 | } | |
63 | } | |
64 | ||
65 | this.VIDEO_DESCRIPTION = { | |
66 | VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ], | |
67 | MESSAGES: { | |
68 | 'minlength': this.i18n('Video description must be at least 3 characters long.'), | |
69 | 'maxlength': this.i18n('Video description cannot be more than 10000 characters long.') | |
70 | } | |
71 | } | |
72 | ||
73 | this.VIDEO_TAGS = { | |
74 | VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ], | |
75 | MESSAGES: { | |
76 | 'minlength': this.i18n('A tag should be more than 2 characters long.'), | |
77 | 'maxlength': this.i18n('A tag should be less than 30 characters long.') | |
78 | } | |
79 | } | |
80 | ||
81 | this.VIDEO_SUPPORT = { | |
82 | VALIDATORS: [ Validators.minLength(3), Validators.maxLength(1000) ], | |
83 | MESSAGES: { | |
84 | 'minlength': this.i18n('Video support must be at least 3 characters long.'), | |
85 | 'maxlength': this.i18n('Video support cannot be more than 1000 characters long.') | |
86 | } | |
87 | } | |
88 | ||
89 | this.VIDEO_SCHEDULE_PUBLICATION_AT = { | |
90 | VALIDATORS: [ ], | |
91 | MESSAGES: { | |
92 | 'required': this.i18n('A date is required to schedule video update.') | |
93 | } | |
94 | } | |
95 | } | |
96 | } |