diff options
author | Chocobozzz <me@florianbigard.com> | 2020-08-17 11:47:04 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-08-17 15:12:55 +0200 |
commit | 7ed1edbbe4ffbef28093e4f5630751cb652814e4 (patch) | |
tree | 831862165dbfce593447a517c2294a7a4c28d840 /client/src/app/shared/form-validators/custom-config-validators.ts | |
parent | 1a95f0b9627f8016767a5a386620cbc3335d5f93 (diff) | |
download | PeerTube-7ed1edbbe4ffbef28093e4f5630751cb652814e4.tar.gz PeerTube-7ed1edbbe4ffbef28093e4f5630751cb652814e4.tar.zst PeerTube-7ed1edbbe4ffbef28093e4f5630751cb652814e4.zip |
We don't need services anymore for validators
Diffstat (limited to 'client/src/app/shared/form-validators/custom-config-validators.ts')
-rw-r--r-- | client/src/app/shared/form-validators/custom-config-validators.ts | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/client/src/app/shared/form-validators/custom-config-validators.ts b/client/src/app/shared/form-validators/custom-config-validators.ts new file mode 100644 index 000000000..41b3cbba9 --- /dev/null +++ b/client/src/app/shared/form-validators/custom-config-validators.ts | |||
@@ -0,0 +1,80 @@ | |||
1 | import { Validators } from '@angular/forms' | ||
2 | import { BuildFormValidator } from './form-validator.model' | ||
3 | |||
4 | export const INSTANCE_NAME_VALIDATOR: BuildFormValidator = { | ||
5 | VALIDATORS: [Validators.required], | ||
6 | MESSAGES: { | ||
7 | 'required': $localize`Instance name is required.` | ||
8 | } | ||
9 | } | ||
10 | |||
11 | export 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 | |||
18 | export const SERVICES_TWITTER_USERNAME_VALIDATOR: BuildFormValidator = { | ||
19 | VALIDATORS: [Validators.required], | ||
20 | MESSAGES: { | ||
21 | 'required': $localize`Twitter username is required.` | ||
22 | } | ||
23 | } | ||
24 | |||
25 | export 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 | |||
34 | export 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 | |||
43 | export 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 | |||
52 | export 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 | |||
60 | export 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 | |||
68 | export const INDEX_URL_VALIDATOR: BuildFormValidator = { | ||
69 | VALIDATORS: [Validators.pattern(/^https:\/\//)], | ||
70 | MESSAGES: { | ||
71 | 'pattern': $localize`Index URL should be a URL` | ||
72 | } | ||
73 | } | ||
74 | |||
75 | export const SEARCH_INDEX_URL_VALIDATOR: BuildFormValidator = { | ||
76 | VALIDATORS: [Validators.pattern(/^https?:\/\//)], | ||
77 | MESSAGES: { | ||
78 | 'pattern': $localize`Search index URL should be a URL` | ||
79 | } | ||
80 | } | ||