]>
Commit | Line | Data |
---|---|---|
e309822b C |
1 | import { Validators } from '@angular/forms' |
2 | import { I18n } from '@ngx-translate/i18n-polyfill' | |
3 | import { BuildFormValidator } from '@app/shared' | |
4 | import { Injectable } from '@angular/core' | |
5 | ||
6 | @Injectable() | |
7 | export class CustomConfigValidatorsService { | |
8 | readonly INSTANCE_NAME: BuildFormValidator | |
9 | readonly INSTANCE_SHORT_DESCRIPTION: BuildFormValidator | |
10 | readonly SERVICES_TWITTER_USERNAME: BuildFormValidator | |
11 | readonly CACHE_PREVIEWS_SIZE: BuildFormValidator | |
40e87e9e | 12 | readonly CACHE_CAPTIONS_SIZE: BuildFormValidator |
e309822b C |
13 | readonly SIGNUP_LIMIT: BuildFormValidator |
14 | readonly ADMIN_EMAIL: BuildFormValidator | |
15 | readonly TRANSCODING_THREADS: BuildFormValidator | |
16 | ||
17 | constructor (private i18n: I18n) { | |
18 | this.INSTANCE_NAME = { | |
19 | VALIDATORS: [ Validators.required ], | |
20 | MESSAGES: { | |
21 | 'required': this.i18n('Instance name is required.') | |
22 | } | |
23 | } | |
24 | ||
25 | this.INSTANCE_SHORT_DESCRIPTION = { | |
26 | VALIDATORS: [ Validators.max(250) ], | |
27 | MESSAGES: { | |
28 | 'max': this.i18n('Short description should not be longer than 250 characters.') | |
29 | } | |
30 | } | |
31 | ||
32 | this.SERVICES_TWITTER_USERNAME = { | |
33 | VALIDATORS: [ Validators.required ], | |
34 | MESSAGES: { | |
35 | 'required': this.i18n('Twitter username is required.') | |
36 | } | |
37 | } | |
38 | ||
39 | this.CACHE_PREVIEWS_SIZE = { | |
40 | VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ], | |
41 | MESSAGES: { | |
42 | 'required': this.i18n('Previews cache size is required.'), | |
43 | 'min': this.i18n('Previews cache size must be greater than 1.'), | |
44 | 'pattern': this.i18n('Previews cache size must be a number.') | |
45 | } | |
46 | } | |
47 | ||
40e87e9e C |
48 | this.CACHE_CAPTIONS_SIZE = { |
49 | VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ], | |
50 | MESSAGES: { | |
51 | 'required': this.i18n('Captions cache size is required.'), | |
52 | 'min': this.i18n('Captions cache size must be greater than 1.'), | |
53 | 'pattern': this.i18n('Captions cache size must be a number.') | |
54 | } | |
55 | } | |
56 | ||
e309822b C |
57 | this.SIGNUP_LIMIT = { |
58 | VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ], | |
59 | MESSAGES: { | |
60 | 'required': this.i18n('Signup limit is required.'), | |
61 | 'min': this.i18n('Signup limit must be greater than 1.'), | |
62 | 'pattern': this.i18n('Signup limit must be a number.') | |
63 | } | |
64 | } | |
65 | ||
66 | this.ADMIN_EMAIL = { | |
67 | VALIDATORS: [ Validators.required, Validators.email ], | |
68 | MESSAGES: { | |
69 | 'required': this.i18n('Admin email is required.'), | |
70 | 'email': this.i18n('Admin email must be valid.') | |
71 | } | |
72 | } | |
73 | ||
74 | this.TRANSCODING_THREADS = { | |
9e912376 | 75 | VALIDATORS: [ Validators.required, Validators.min(0) ], |
e309822b C |
76 | MESSAGES: { |
77 | 'required': this.i18n('Transcoding threads is required.'), | |
9e912376 | 78 | 'min': this.i18n('Transcoding threads must be greater or equal to 0.') |
e309822b C |
79 | } |
80 | } | |
81 | } | |
82 | } |