aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/form-validators/custom-config-validators.ts
blob: ff0813f7d821e53cd133d00e6708149c74154963 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import { Validators } from '@angular/forms'
import { BuildFormValidator } from './form-validator.model'

export const INSTANCE_NAME_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required ],
  MESSAGES: {
    required: $localize`Instance name is required.`
  }
}

export const INSTANCE_SHORT_DESCRIPTION_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.maxLength(250) ],
  MESSAGES: {
    maxlength: $localize`Short description should not be longer than 250 characters.`
  }
}

export const SERVICES_TWITTER_USERNAME_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required ],
  MESSAGES: {
    required: $localize`Twitter username is required.`
  }
}

export const CACHE_PREVIEWS_SIZE_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
  MESSAGES: {
    required: $localize`Previews cache size is required.`,
    min: $localize`Previews cache size must be greater than 1.`,
    pattern: $localize`Previews cache size must be a number.`
  }
}

export const CACHE_CAPTIONS_SIZE_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
  MESSAGES: {
    required: $localize`Captions cache size is required.`,
    min: $localize`Captions cache size must be greater than 1.`,
    pattern: $localize`Captions cache size must be a number.`
  }
}

export const SIGNUP_LIMIT_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.min(-1), Validators.pattern('-?[0-9]+') ],
  MESSAGES: {
    required: $localize`Signup limit is required.`,
    min: $localize`Signup limit must be greater than 1. Use -1 to disable it.`,
    pattern: $localize`Signup limit must be a number.`
  }
}

export const SIGNUP_MINIMUM_AGE_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
  MESSAGES: {
    required: $localize`Signup minimum age is required.`,
    min: $localize`Signup minimum age must be greater than 1.`,
    pattern: $localize`Signup minimum age must be a number.`
  }
}

export const ADMIN_EMAIL_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.email ],
  MESSAGES: {
    required: $localize`Admin email is required.`,
    email: $localize`Admin email must be valid.`
  }
}

export const TRANSCODING_THREADS_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.min(0) ],
  MESSAGES: {
    required: $localize`Transcoding threads is required.`,
    min: $localize`Transcoding threads must be greater or equal to 0.`
  }
}

export const MAX_LIVE_DURATION_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.min(-1) ],
  MESSAGES: {
    required: $localize`Max live duration is required.`,
    min: $localize`Max live duration should be greater or equal to -1.`
  }
}

export const MAX_INSTANCE_LIVES_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.min(-1) ],
  MESSAGES: {
    required: $localize`Max instance lives is required.`,
    min: $localize`Max instance lives should be greater or equal to -1.`
  }
}

export const MAX_USER_LIVES_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.min(-1) ],
  MESSAGES: {
    required: $localize`Max user lives is required.`,
    min: $localize`Max user lives should be greater or equal to -1.`
  }
}

export const MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
  MESSAGES: {
    required: $localize`Max video channels per user is required.`,
    min: $localize`Max video channels per user must be greater or equal to 1.`,
    pattern: $localize`Max video channels per user must be a number.`
  }
}

export const CONCURRENCY_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.min(1) ],
  MESSAGES: {
    required: $localize`Concurrency is required.`,
    min: $localize`Concurrency should be greater or equal to 1.`
  }
}

export const INDEX_URL_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.pattern(/^https:\/\//) ],
  MESSAGES: {
    pattern: $localize`Index URL should be a URL`
  }
}

export const SEARCH_INDEX_URL_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.pattern(/^https?:\/\//) ],
  MESSAGES: {
    pattern: $localize`Search index URL should be a URL`
  }
}