]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/forms/form-validators/video-validators.service.ts
76fc5cf04318efa12faa86f552b05485c754c9f4
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / forms / form-validators / video-validators.service.ts
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
19 constructor (private i18n: I18n) {
20
21 this.VIDEO_NAME = {
22 VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ],
23 MESSAGES: {
24 'required': this.i18n('Video name is required.'),
25 'minlength': this.i18n('Video name must be at least 3 characters long.'),
26 'maxlength': this.i18n('Video name cannot be more than 120 characters long.')
27 }
28 }
29
30 this.VIDEO_PRIVACY = {
31 VALIDATORS: [ Validators.required ],
32 MESSAGES: {
33 'required': this.i18n('Video privacy is required.')
34 }
35 }
36
37 this.VIDEO_CATEGORY = {
38 VALIDATORS: [ ],
39 MESSAGES: {}
40 }
41
42 this.VIDEO_LICENCE = {
43 VALIDATORS: [ ],
44 MESSAGES: {}
45 }
46
47 this.VIDEO_LANGUAGE = {
48 VALIDATORS: [ ],
49 MESSAGES: {}
50 }
51
52 this.VIDEO_IMAGE = {
53 VALIDATORS: [ ],
54 MESSAGES: {}
55 }
56
57 this.VIDEO_CHANNEL = {
58 VALIDATORS: [ Validators.required ],
59 MESSAGES: {
60 'required': this.i18n('Video channel is required.')
61 }
62 }
63
64 this.VIDEO_DESCRIPTION = {
65 VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ],
66 MESSAGES: {
67 'minlength': this.i18n('Video description must be at least 3 characters long.'),
68 'maxlength': this.i18n('Video description cannot be more than 10000 characters long.')
69 }
70 }
71
72 this.VIDEO_TAGS = {
73 VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ],
74 MESSAGES: {
75 'minlength': this.i18n('A tag should be more than 2 characters long.'),
76 'maxlength': this.i18n('A tag should be less than 30 characters long.')
77 }
78 }
79
80 this.VIDEO_SUPPORT = {
81 VALIDATORS: [ Validators.minLength(3), Validators.maxLength(500) ],
82 MESSAGES: {
83 'minlength': this.i18n('Video support must be at least 3 characters long.'),
84 'maxlength': this.i18n('Video support cannot be more than 500 characters long.')
85 }
86 }
87 }
88 }