]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/form-validators/custom-config-validators.ts
Refactor video miniature
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / form-validators / custom-config-validators.ts
CommitLineData
7ed1edbb
C
1import { Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3
4export const INSTANCE_NAME_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [Validators.required],
6 MESSAGES: {
7 'required': $localize`Instance name is required.`
8 }
9}
10
11export const INSTANCE_SHORT_DESCRIPTION_VALIDATOR: BuildFormValidator = {
12 VALIDATORS: [Validators.max(250)],
13 MESSAGES: {
14 'max': $localize`Short description should not be longer than 250 characters.`
15 }
16}
17
18export const SERVICES_TWITTER_USERNAME_VALIDATOR: BuildFormValidator = {
19 VALIDATORS: [Validators.required],
20 MESSAGES: {
21 'required': $localize`Twitter username is required.`
22 }
23}
24
25export const CACHE_PREVIEWS_SIZE_VALIDATOR: BuildFormValidator = {
26 VALIDATORS: [Validators.required, Validators.min(1), Validators.pattern('[0-9]+')],
27 MESSAGES: {
28 'required': $localize`Previews cache size is required.`,
29 'min': $localize`Previews cache size must be greater than 1.`,
30 'pattern': $localize`Previews cache size must be a number.`
31 }
32}
33
34export const CACHE_CAPTIONS_SIZE_VALIDATOR: BuildFormValidator = {
35 VALIDATORS: [Validators.required, Validators.min(1), Validators.pattern('[0-9]+')],
36 MESSAGES: {
37 'required': $localize`Captions cache size is required.`,
38 'min': $localize`Captions cache size must be greater than 1.`,
39 'pattern': $localize`Captions cache size must be a number.`
40 }
41}
42
43export const SIGNUP_LIMIT_VALIDATOR: BuildFormValidator = {
44 VALIDATORS: [Validators.required, Validators.min(-1), Validators.pattern('-?[0-9]+')],
45 MESSAGES: {
46 'required': $localize`Signup limit is required.`,
47 'min': $localize`Signup limit must be greater than 1.`,
48 'pattern': $localize`Signup limit must be a number.`
49 }
50}
51
52export const ADMIN_EMAIL_VALIDATOR: BuildFormValidator = {
53 VALIDATORS: [Validators.required, Validators.email],
54 MESSAGES: {
55 'required': $localize`Admin email is required.`,
56 'email': $localize`Admin email must be valid.`
57 }
58}
59
60export const TRANSCODING_THREADS_VALIDATOR: BuildFormValidator = {
61 VALIDATORS: [Validators.required, Validators.min(0)],
62 MESSAGES: {
63 'required': $localize`Transcoding threads is required.`,
64 'min': $localize`Transcoding threads must be greater or equal to 0.`
65 }
66}
67
4e55c132
C
68export const MAX_LIVE_DURATION_VALIDATOR: BuildFormValidator = {
69 VALIDATORS: [Validators.required, Validators.min(-1)],
70 MESSAGES: {
71 'required': $localize`Max live duration is required.`,
72 'min': $localize`Max live duration should be greater or equal to -1.`
73 }
74}
75
76export const MAX_INSTANCE_LIVES_VALIDATOR: BuildFormValidator = {
77 VALIDATORS: [Validators.required, Validators.min(-1)],
78 MESSAGES: {
79 'required': $localize`Max instance lives is required.`,
80 'min': $localize`Max instance lives should be greater or equal to -1.`
81 }
82}
83
84export const MAX_USER_LIVES_VALIDATOR: BuildFormValidator = {
85 VALIDATORS: [Validators.required, Validators.min(-1)],
86 MESSAGES: {
87 'required': $localize`Max user lives is required.`,
88 'min': $localize`Max user lives should be greater or equal to -1.`
89 }
90}
91
9129b769
C
92export const CONCURRENCY_VALIDATOR: BuildFormValidator = {
93 VALIDATORS: [Validators.required, Validators.min(1)],
94 MESSAGES: {
95 'required': $localize`Concurrency is required.`,
96 'min': $localize`Concurrency should be greater or equal to 1.`
97 }
98}
99
7ed1edbb
C
100export const INDEX_URL_VALIDATOR: BuildFormValidator = {
101 VALIDATORS: [Validators.pattern(/^https:\/\//)],
102 MESSAGES: {
103 'pattern': $localize`Index URL should be a URL`
104 }
105}
106
107export const SEARCH_INDEX_URL_VALIDATOR: BuildFormValidator = {
108 VALIDATORS: [Validators.pattern(/^https?:\/\//)],
109 MESSAGES: {
110 'pattern': $localize`Search index URL should be a URL`
111 }
112}