]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/form-validators/video-channel-validators.ts
We don't need services anymore for validators
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / form-validators / video-channel-validators.ts
1 import { Validators } from '@angular/forms'
2 import { BuildFormValidator } from './form-validator.model'
3
4 export const VIDEO_CHANNEL_NAME_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [
6 Validators.required,
7 Validators.minLength(1),
8 Validators.maxLength(50),
9 Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
10 ],
11 MESSAGES: {
12 'required': $localize`Name is required.`,
13 'minlength': $localize`Name must be at least 1 character long.`,
14 'maxlength': $localize`Name cannot be more than 50 characters long.`,
15 'pattern': $localize`Name should be lowercase alphanumeric; dots and underscores are allowed.`
16 }
17 }
18
19 export const VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR: BuildFormValidator = {
20 VALIDATORS: [
21 Validators.required,
22 Validators.minLength(1),
23 Validators.maxLength(50)
24 ],
25 MESSAGES: {
26 'required': $localize`Display name is required.`,
27 'minlength': $localize`Display name must be at least 1 character long.`,
28 'maxlength': $localize`Display name cannot be more than 50 characters long.`
29 }
30 }
31
32 export const VIDEO_CHANNEL_DESCRIPTION_VALIDATOR: BuildFormValidator = {
33 VALIDATORS: [
34 Validators.minLength(3),
35 Validators.maxLength(1000)
36 ],
37 MESSAGES: {
38 'minlength': $localize`Description must be at least 3 characters long.`,
39 'maxlength': $localize`Description cannot be more than 1000 characters long.`
40 }
41 }
42
43 export const VIDEO_CHANNEL_SUPPORT_VALIDATOR: BuildFormValidator = {
44 VALIDATORS: [
45 Validators.minLength(3),
46 Validators.maxLength(1000)
47 ],
48 MESSAGES: {
49 'minlength': $localize`Support text must be at least 3 characters long.`,
50 'maxlength': $localize`Support text cannot be more than 1000 characters long`
51 }
52 }