Add form validator translations
[oweals/peertube.git] / client / src / app / shared / forms / form-validators / video-channel-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 VideoChannelValidatorsService {
8   readonly VIDEO_CHANNEL_DISPLAY_NAME: BuildFormValidator
9   readonly VIDEO_CHANNEL_DESCRIPTION: BuildFormValidator
10   readonly VIDEO_CHANNEL_SUPPORT: BuildFormValidator
11
12   constructor (private i18n: I18n) {
13     this.VIDEO_CHANNEL_DISPLAY_NAME = {
14       VALIDATORS: [
15         Validators.required,
16         Validators.minLength(3),
17         Validators.maxLength(120)
18       ],
19       MESSAGES: {
20         'required': i18n('Display name is required.'),
21         'minlength': i18n('Display name must be at least 3 characters long.'),
22         'maxlength': i18n('Display name cannot be more than 120 characters long.')
23       }
24     }
25
26     this.VIDEO_CHANNEL_DESCRIPTION = {
27       VALIDATORS: [
28         Validators.minLength(3),
29         Validators.maxLength(500)
30       ],
31       MESSAGES: {
32         'minlength': i18n('Description must be at least 3 characters long.'),
33         'maxlength': i18n('Description cannot be more than 500 characters long.')
34       }
35     }
36
37     this.VIDEO_CHANNEL_SUPPORT = {
38       VALIDATORS: [
39         Validators.minLength(3),
40         Validators.maxLength(500)
41       ],
42       MESSAGES: {
43         'minlength': i18n('Support text must be at least 3 characters long.'),
44         'maxlength': i18n('Support text cannot be more than 500 characters long.')
45       }
46     }
47   }
48 }