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/instance-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/instance-validators.ts')
-rw-r--r-- | client/src/app/shared/form-validators/instance-validators.ts | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/client/src/app/shared/form-validators/instance-validators.ts b/client/src/app/shared/form-validators/instance-validators.ts new file mode 100644 index 000000000..a72e28ba0 --- /dev/null +++ b/client/src/app/shared/form-validators/instance-validators.ts | |||
@@ -0,0 +1,49 @@ | |||
1 | import { Validators } from '@angular/forms' | ||
2 | import { BuildFormValidator } from './form-validator.model' | ||
3 | |||
4 | export const FROM_EMAIL_VALIDATOR: BuildFormValidator = { | ||
5 | VALIDATORS: [Validators.required, Validators.email], | ||
6 | MESSAGES: { | ||
7 | 'required': $localize`Email is required.`, | ||
8 | 'email': $localize`Email must be valid.` | ||
9 | } | ||
10 | } | ||
11 | |||
12 | export const FROM_NAME_VALIDATOR: BuildFormValidator = { | ||
13 | VALIDATORS: [ | ||
14 | Validators.required, | ||
15 | Validators.minLength(1), | ||
16 | Validators.maxLength(120) | ||
17 | ], | ||
18 | MESSAGES: { | ||
19 | 'required': $localize`Your name is required.`, | ||
20 | 'minlength': $localize`Your name must be at least 1 character long.`, | ||
21 | 'maxlength': $localize`Your name cannot be more than 120 characters long.` | ||
22 | } | ||
23 | } | ||
24 | |||
25 | export const SUBJECT_VALIDATOR: BuildFormValidator = { | ||
26 | VALIDATORS: [ | ||
27 | Validators.required, | ||
28 | Validators.minLength(1), | ||
29 | Validators.maxLength(120) | ||
30 | ], | ||
31 | MESSAGES: { | ||
32 | 'required': $localize`A subject is required.`, | ||
33 | 'minlength': $localize`The subject must be at least 1 character long.`, | ||
34 | 'maxlength': $localize`The subject cannot be more than 120 characters long.` | ||
35 | } | ||
36 | } | ||
37 | |||
38 | export const BODY_VALIDATOR: BuildFormValidator = { | ||
39 | VALIDATORS: [ | ||
40 | Validators.required, | ||
41 | Validators.minLength(3), | ||
42 | Validators.maxLength(5000) | ||
43 | ], | ||
44 | MESSAGES: { | ||
45 | 'required': $localize`A message is required.`, | ||
46 | 'minlength': $localize`The message must be at least 3 characters long.`, | ||
47 | 'maxlength': $localize`The message cannot be more than 5000 characters long.` | ||
48 | } | ||
49 | } | ||