]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-forms/form-validators/custom-config-validators.service.ts
Migrate to $localize
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-forms / form-validators / custom-config-validators.service.ts
CommitLineData
66357162 1import { Injectable } from '@angular/core'
e309822b 2import { Validators } from '@angular/forms'
67ed6552 3import { BuildFormValidator } from './form-validator.service'
e309822b
C
4
5@Injectable()
6export class CustomConfigValidatorsService {
7 readonly INSTANCE_NAME: BuildFormValidator
8 readonly INSTANCE_SHORT_DESCRIPTION: BuildFormValidator
9 readonly SERVICES_TWITTER_USERNAME: BuildFormValidator
10 readonly CACHE_PREVIEWS_SIZE: BuildFormValidator
40e87e9e 11 readonly CACHE_CAPTIONS_SIZE: BuildFormValidator
e309822b
C
12 readonly SIGNUP_LIMIT: BuildFormValidator
13 readonly ADMIN_EMAIL: BuildFormValidator
14 readonly TRANSCODING_THREADS: BuildFormValidator
e1b49ee5 15 readonly INDEX_URL: BuildFormValidator
5fb2e288 16 readonly SEARCH_INDEX_URL: BuildFormValidator
e309822b 17
66357162 18 constructor () {
e309822b
C
19 this.INSTANCE_NAME = {
20 VALIDATORS: [ Validators.required ],
21 MESSAGES: {
66357162 22 'required': $localize`Instance name is required.`
e309822b
C
23 }
24 }
25
26 this.INSTANCE_SHORT_DESCRIPTION = {
27 VALIDATORS: [ Validators.max(250) ],
28 MESSAGES: {
66357162 29 'max': $localize`Short description should not be longer than 250 characters.`
e309822b
C
30 }
31 }
32
33 this.SERVICES_TWITTER_USERNAME = {
34 VALIDATORS: [ Validators.required ],
35 MESSAGES: {
66357162 36 'required': $localize`Twitter username is required.`
e309822b
C
37 }
38 }
39
40 this.CACHE_PREVIEWS_SIZE = {
41 VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
42 MESSAGES: {
66357162
C
43 'required': $localize`Previews cache size is required.`,
44 'min': $localize`Previews cache size must be greater than 1.`,
45 'pattern': $localize`Previews cache size must be a number.`
e309822b
C
46 }
47 }
48
40e87e9e
C
49 this.CACHE_CAPTIONS_SIZE = {
50 VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
51 MESSAGES: {
66357162
C
52 'required': $localize`Captions cache size is required.`,
53 'min': $localize`Captions cache size must be greater than 1.`,
54 'pattern': $localize`Captions cache size must be a number.`
40e87e9e
C
55 }
56 }
57
e309822b 58 this.SIGNUP_LIMIT = {
e40afb5b 59 VALIDATORS: [ Validators.required, Validators.min(-1), Validators.pattern('-?[0-9]+') ],
e309822b 60 MESSAGES: {
66357162
C
61 'required': $localize`Signup limit is required.`,
62 'min': $localize`Signup limit must be greater than 1.`,
63 'pattern': $localize`Signup limit must be a number.`
e309822b
C
64 }
65 }
66
67 this.ADMIN_EMAIL = {
68 VALIDATORS: [ Validators.required, Validators.email ],
69 MESSAGES: {
66357162
C
70 'required': $localize`Admin email is required.`,
71 'email': $localize`Admin email must be valid.`
e309822b
C
72 }
73 }
74
75 this.TRANSCODING_THREADS = {
9e912376 76 VALIDATORS: [ Validators.required, Validators.min(0) ],
e309822b 77 MESSAGES: {
66357162
C
78 'required': $localize`Transcoding threads is required.`,
79 'min': $localize`Transcoding threads must be greater or equal to 0.`
e309822b
C
80 }
81 }
e1b49ee5
C
82
83 this.INDEX_URL = {
92128fff 84 VALIDATORS: [ Validators.pattern(/^https:\/\//) ],
e1b49ee5 85 MESSAGES: {
66357162 86 'pattern': $localize`Index URL should be a URL`
e1b49ee5
C
87 }
88 }
5fb2e288
C
89
90 this.SEARCH_INDEX_URL = {
91 VALIDATORS: [ Validators.pattern(/^https?:\/\//) ],
92 MESSAGES: {
66357162 93 'pattern': $localize`Search index URL should be a URL`
5fb2e288
C
94 }
95 }
e309822b
C
96 }
97}