]>
Commit | Line | Data |
---|---|---|
7ed1edbb C |
1 | import { Validators } from '@angular/forms' |
2 | import { BuildFormValidator } from './form-validator.model' | |
27db7840 | 3 | import { USER_USERNAME_VALIDATOR } from './user-validators' |
7ed1edbb C |
4 | |
5 | export const VIDEO_CHANNEL_NAME_VALIDATOR: BuildFormValidator = { | |
27db7840 C |
6 | // Use the same constraints than user usernmae |
7 | VALIDATORS: USER_USERNAME_VALIDATOR.VALIDATORS, | |
8 | ||
7ed1edbb | 9 | MESSAGES: { |
9df52d66 C |
10 | required: $localize`Name is required.`, |
11 | minlength: $localize`Name must be at least 1 character long.`, | |
12 | maxlength: $localize`Name cannot be more than 50 characters long.`, | |
13 | pattern: $localize`Name should be lowercase alphanumeric; dots and underscores are allowed.` | |
7ed1edbb C |
14 | } |
15 | } | |
16 | ||
17 | export const VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR: BuildFormValidator = { | |
18 | VALIDATORS: [ | |
19 | Validators.required, | |
20 | Validators.minLength(1), | |
21 | Validators.maxLength(50) | |
22 | ], | |
23 | MESSAGES: { | |
9df52d66 C |
24 | required: $localize`Display name is required.`, |
25 | minlength: $localize`Display name must be at least 1 character long.`, | |
26 | maxlength: $localize`Display name cannot be more than 50 characters long.` | |
7ed1edbb C |
27 | } |
28 | } | |
29 | ||
30 | export const VIDEO_CHANNEL_DESCRIPTION_VALIDATOR: BuildFormValidator = { | |
31 | VALIDATORS: [ | |
32 | Validators.minLength(3), | |
33 | Validators.maxLength(1000) | |
34 | ], | |
35 | MESSAGES: { | |
9df52d66 C |
36 | minlength: $localize`Description must be at least 3 characters long.`, |
37 | maxlength: $localize`Description cannot be more than 1000 characters long.` | |
7ed1edbb C |
38 | } |
39 | } | |
40 | ||
41 | export const VIDEO_CHANNEL_SUPPORT_VALIDATOR: BuildFormValidator = { | |
42 | VALIDATORS: [ | |
43 | Validators.minLength(3), | |
44 | Validators.maxLength(1000) | |
45 | ], | |
46 | MESSAGES: { | |
9df52d66 | 47 | minlength: $localize`Support text must be at least 3 characters long.`, |
0cc85266 | 48 | maxlength: $localize`Support text cannot be more than 1000 characters long.` |
7ed1edbb C |
49 | } |
50 | } | |
2a491182 F |
51 | |
52 | export const VIDEO_CHANNEL_EXTERNAL_URL_VALIDATOR: BuildFormValidator = { | |
53 | VALIDATORS: [ | |
54 | Validators.required, | |
55 | Validators.pattern(/^https?:\/\//), | |
56 | Validators.maxLength(1000) | |
57 | ], | |
58 | MESSAGES: { | |
59 | required: $localize`Remote channel url is required.`, | |
60 | pattern: $localize`External channel URL must begin with "https://" or "http://"`, | |
61 | maxlength: $localize`External channel URL cannot be more than 1000 characters long` | |
62 | } | |
63 | } |