]>
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 VideoChannelValidatorsService { | |
8a19bee1 | 8 | readonly VIDEO_CHANNEL_NAME: BuildFormValidator |
e309822b C |
9 | readonly VIDEO_CHANNEL_DISPLAY_NAME: BuildFormValidator |
10 | readonly VIDEO_CHANNEL_DESCRIPTION: BuildFormValidator | |
11 | readonly VIDEO_CHANNEL_SUPPORT: BuildFormValidator | |
12 | ||
13 | constructor (private i18n: I18n) { | |
8a19bee1 C |
14 | this.VIDEO_CHANNEL_NAME = { |
15 | VALIDATORS: [ | |
16 | Validators.required, | |
d0ce42c1 BY |
17 | Validators.minLength(1), |
18 | Validators.maxLength(50), | |
6ebfaf67 | 19 | Validators.pattern(/^[a-z0-9][a-z0-9._]*$/) |
8a19bee1 C |
20 | ], |
21 | MESSAGES: { | |
22 | 'required': this.i18n('Name is required.'), | |
d0ce42c1 BY |
23 | 'minlength': this.i18n('Name must be at least 1 character long.'), |
24 | 'maxlength': this.i18n('Name cannot be more than 50 characters long.'), | |
4523bf11 | 25 | 'pattern': this.i18n('Name should be lowercase alphanumeric; dots and underscores are allowed.') |
8a19bee1 C |
26 | } |
27 | } | |
28 | ||
e309822b C |
29 | this.VIDEO_CHANNEL_DISPLAY_NAME = { |
30 | VALIDATORS: [ | |
31 | Validators.required, | |
d0ce42c1 BY |
32 | Validators.minLength(1), |
33 | Validators.maxLength(50) | |
e309822b C |
34 | ], |
35 | MESSAGES: { | |
36 | 'required': i18n('Display name is required.'), | |
d0ce42c1 BY |
37 | 'minlength': i18n('Display name must be at least 1 character long.'), |
38 | 'maxlength': i18n('Display name cannot be more than 50 characters long.') | |
e309822b C |
39 | } |
40 | } | |
41 | ||
42 | this.VIDEO_CHANNEL_DESCRIPTION = { | |
43 | VALIDATORS: [ | |
44 | Validators.minLength(3), | |
d23e6a1c | 45 | Validators.maxLength(1000) |
e309822b C |
46 | ], |
47 | MESSAGES: { | |
48 | 'minlength': i18n('Description must be at least 3 characters long.'), | |
d23e6a1c | 49 | 'maxlength': i18n('Description cannot be more than 1000 characters long.') |
e309822b C |
50 | } |
51 | } | |
52 | ||
53 | this.VIDEO_CHANNEL_SUPPORT = { | |
54 | VALIDATORS: [ | |
55 | Validators.minLength(3), | |
d23e6a1c | 56 | Validators.maxLength(1000) |
e309822b C |
57 | ], |
58 | MESSAGES: { | |
59 | 'minlength': i18n('Support text must be at least 3 characters long.'), | |
d23e6a1c | 60 | 'maxlength': i18n('Support text cannot be more than 1000 characters long.') |
e309822b C |
61 | } |
62 | } | |
63 | } | |
64 | } |