]>
Commit | Line | Data |
---|---|---|
1 | import { Injectable } from '@angular/core' | |
2 | import { Validators } from '@angular/forms' | |
3 | import { BuildFormValidator } from './form-validator.service' | |
4 | ||
5 | @Injectable() | |
6 | export class VideoChannelValidatorsService { | |
7 | readonly VIDEO_CHANNEL_NAME: BuildFormValidator | |
8 | readonly VIDEO_CHANNEL_DISPLAY_NAME: BuildFormValidator | |
9 | readonly VIDEO_CHANNEL_DESCRIPTION: BuildFormValidator | |
10 | readonly VIDEO_CHANNEL_SUPPORT: BuildFormValidator | |
11 | ||
12 | constructor () { | |
13 | this.VIDEO_CHANNEL_NAME = { | |
14 | VALIDATORS: [ | |
15 | Validators.required, | |
16 | Validators.minLength(1), | |
17 | Validators.maxLength(50), | |
18 | Validators.pattern(/^[a-z0-9][a-z0-9._]*$/) | |
19 | ], | |
20 | MESSAGES: { | |
21 | 'required': $localize`Name is required.`, | |
22 | 'minlength': $localize`Name must be at least 1 character long.`, | |
23 | 'maxlength': $localize`Name cannot be more than 50 characters long.`, | |
24 | 'pattern': $localize`Name should be lowercase alphanumeric; dots and underscores are allowed.` | |
25 | } | |
26 | } | |
27 | ||
28 | this.VIDEO_CHANNEL_DISPLAY_NAME = { | |
29 | VALIDATORS: [ | |
30 | Validators.required, | |
31 | Validators.minLength(1), | |
32 | Validators.maxLength(50) | |
33 | ], | |
34 | MESSAGES: { | |
35 | 'required': $localize`Display name is required.`, | |
36 | 'minlength': $localize`Display name must be at least 1 character long.`, | |
37 | 'maxlength': $localize`Display name cannot be more than 50 characters long.` | |
38 | } | |
39 | } | |
40 | ||
41 | this.VIDEO_CHANNEL_DESCRIPTION = { | |
42 | VALIDATORS: [ | |
43 | Validators.minLength(3), | |
44 | Validators.maxLength(1000) | |
45 | ], | |
46 | MESSAGES: { | |
47 | 'minlength': $localize`Description must be at least 3 characters long.`, | |
48 | 'maxlength': $localize`Description cannot be more than 1000 characters long.` | |
49 | } | |
50 | } | |
51 | ||
52 | this.VIDEO_CHANNEL_SUPPORT = { | |
53 | VALIDATORS: [ | |
54 | Validators.minLength(3), | |
55 | Validators.maxLength(1000) | |
56 | ], | |
57 | MESSAGES: { | |
58 | 'minlength': $localize`Support text must be at least 3 characters long.`, | |
59 | 'maxlength': $localize`Support text cannot be more than 1000 characters long` | |
60 | } | |
61 | } | |
62 | } | |
63 | } |