aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-17 11:47:04 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-08-17 15:12:55 +0200
commit7ed1edbbe4ffbef28093e4f5630751cb652814e4 (patch)
tree831862165dbfce593447a517c2294a7a4c28d840 /client/src/app/shared
parent1a95f0b9627f8016767a5a386620cbc3335d5f93 (diff)
downloadPeerTube-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')
-rw-r--r--client/src/app/shared/form-validators/abuse-validators.ts29
-rw-r--r--client/src/app/shared/form-validators/batch-domains-validators.ts60
-rw-r--r--client/src/app/shared/form-validators/custom-config-validators.ts80
-rw-r--r--client/src/app/shared/form-validators/form-validator.model.ts14
-rw-r--r--client/src/app/shared/form-validators/host.ts (renamed from client/src/app/shared/shared-forms/form-validators/host.ts)0
-rw-r--r--client/src/app/shared/form-validators/index.ts17
-rw-r--r--client/src/app/shared/form-validators/instance-validators.ts49
-rw-r--r--client/src/app/shared/form-validators/login-validators.ts20
-rw-r--r--client/src/app/shared/form-validators/reset-password-validators.ts11
-rw-r--r--client/src/app/shared/form-validators/user-validators.ts144
-rw-r--r--client/src/app/shared/form-validators/video-block-validators.ts10
-rw-r--r--client/src/app/shared/form-validators/video-captions-validators.ts16
-rw-r--r--client/src/app/shared/form-validators/video-channel-validators.ts52
-rw-r--r--client/src/app/shared/form-validators/video-comment-validators.ts11
-rw-r--r--client/src/app/shared/form-validators/video-ownership-change-validators.ts25
-rw-r--r--client/src/app/shared/form-validators/video-playlist-validators.ts54
-rw-r--r--client/src/app/shared/form-validators/video-validators.ts101
-rw-r--r--client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts6
-rw-r--r--client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts8
-rw-r--r--client/src/app/shared/shared-forms/form-reactive.ts3
-rw-r--r--client/src/app/shared/shared-forms/form-validator.service.ts (renamed from client/src/app/shared/shared-forms/form-validators/form-validator.service.ts)16
-rw-r--r--client/src/app/shared/shared-forms/form-validators/abuse-validators.service.ts39
-rw-r--r--client/src/app/shared/shared-forms/form-validators/batch-domains-validators.service.ts68
-rw-r--r--client/src/app/shared/shared-forms/form-validators/custom-config-validators.service.ts97
-rw-r--r--client/src/app/shared/shared-forms/form-validators/index.ts17
-rw-r--r--client/src/app/shared/shared-forms/form-validators/instance-validators.service.ts61
-rw-r--r--client/src/app/shared/shared-forms/form-validators/login-validators.service.ts29
-rw-r--r--client/src/app/shared/shared-forms/form-validators/reset-password-validators.service.ts19
-rw-r--r--client/src/app/shared/shared-forms/form-validators/user-validators.service.ts166
-rw-r--r--client/src/app/shared/shared-forms/form-validators/video-accept-ownership-validators.service.ts17
-rw-r--r--client/src/app/shared/shared-forms/form-validators/video-block-validators.service.ts18
-rw-r--r--client/src/app/shared/shared-forms/form-validators/video-captions-validators.service.ts26
-rw-r--r--client/src/app/shared/shared-forms/form-validators/video-change-ownership-validators.service.ts26
-rw-r--r--client/src/app/shared/shared-forms/form-validators/video-channel-validators.service.ts63
-rw-r--r--client/src/app/shared/shared-forms/form-validators/video-comment-validators.service.ts19
-rw-r--r--client/src/app/shared/shared-forms/form-validators/video-playlist-validators.service.ts65
-rw-r--r--client/src/app/shared/shared-forms/form-validators/video-validators.service.ts122
-rw-r--r--client/src/app/shared/shared-forms/index.ts2
-rw-r--r--client/src/app/shared/shared-forms/shared-form.module.ts43
-rw-r--r--client/src/app/shared/shared-moderation/batch-domains-modal.component.ts10
-rw-r--r--client/src/app/shared/shared-moderation/report-modals/account-report.component.ts6
-rw-r--r--client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts6
-rw-r--r--client/src/app/shared/shared-moderation/report-modals/video-report.component.ts6
-rw-r--r--client/src/app/shared/shared-moderation/user-ban-modal.component.ts8
-rw-r--r--client/src/app/shared/shared-moderation/video-block.component.ts6
-rw-r--r--client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts8
-rw-r--r--client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts6
47 files changed, 739 insertions, 940 deletions
diff --git a/client/src/app/shared/form-validators/abuse-validators.ts b/client/src/app/shared/form-validators/abuse-validators.ts
new file mode 100644
index 000000000..75bfacf01
--- /dev/null
+++ b/client/src/app/shared/form-validators/abuse-validators.ts
@@ -0,0 +1,29 @@
1import { Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3
4export const ABUSE_REASON_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [Validators.required, Validators.minLength(2), Validators.maxLength(3000)],
6 MESSAGES: {
7 'required': $localize`Report reason is required.`,
8 'minlength': $localize`Report reason must be at least 2 characters long.`,
9 'maxlength': $localize`Report reason cannot be more than 3000 characters long.`
10 }
11}
12
13export const ABUSE_MODERATION_COMMENT_VALIDATOR: BuildFormValidator = {
14 VALIDATORS: [Validators.required, Validators.minLength(2), Validators.maxLength(3000)],
15 MESSAGES: {
16 'required': $localize`Moderation comment is required.`,
17 'minlength': $localize`Moderation comment must be at least 2 characters long.`,
18 'maxlength': $localize`Moderation comment cannot be more than 3000 characters long.`
19 }
20}
21
22export const ABUSE_MESSAGE_VALIDATOR: BuildFormValidator = {
23 VALIDATORS: [Validators.required, Validators.minLength(2), Validators.maxLength(3000)],
24 MESSAGES: {
25 'required': $localize`Abuse message is required.`,
26 'minlength': $localize`Abuse message must be at least 2 characters long.`,
27 'maxlength': $localize`Abuse message cannot be more than 3000 characters long.`
28 }
29}
diff --git a/client/src/app/shared/form-validators/batch-domains-validators.ts b/client/src/app/shared/form-validators/batch-domains-validators.ts
new file mode 100644
index 000000000..423d1337f
--- /dev/null
+++ b/client/src/app/shared/form-validators/batch-domains-validators.ts
@@ -0,0 +1,60 @@
1import { AbstractControl, FormControl, ValidatorFn, Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3import { validateHost } from './host'
4
5export function getNotEmptyHosts (hosts: string) {
6 return hosts
7 .split('\n')
8 .filter((host: string) => host && host.length !== 0) // Eject empty hosts
9}
10
11const validDomains: ValidatorFn = (control: FormControl) => {
12 if (!control.value) return null
13
14 const newHostsErrors = []
15 const hosts = getNotEmptyHosts(control.value)
16
17 for (const host of hosts) {
18 if (validateHost(host) === false) {
19 newHostsErrors.push($localize`${host} is not valid`)
20 }
21 }
22
23 /* Is not valid. */
24 if (newHostsErrors.length !== 0) {
25 return {
26 'validDomains': {
27 reason: 'invalid',
28 value: newHostsErrors.join('. ') + '.'
29 }
30 }
31 }
32
33 /* Is valid. */
34 return null
35}
36
37const isHostsUnique: ValidatorFn = (control: AbstractControl) => {
38 if (!control.value) return null
39
40 const hosts = getNotEmptyHosts(control.value)
41
42 if (hosts.every((host: string) => hosts.indexOf(host) === hosts.lastIndexOf(host))) {
43 return null
44 } else {
45 return {
46 'uniqueDomains': {
47 reason: 'invalid'
48 }
49 }
50 }
51}
52
53export const DOMAINS_VALIDATOR: BuildFormValidator = {
54 VALIDATORS: [Validators.required, validDomains, isHostsUnique],
55 MESSAGES: {
56 'required': $localize`Domain is required.`,
57 'validDomains': $localize`Domains entered are invalid.`,
58 'uniqueDomains': $localize`Domains entered contain duplicates.`
59 }
60}
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 @@
1import { Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3
4export const INSTANCE_NAME_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [Validators.required],
6 MESSAGES: {
7 'required': $localize`Instance name is required.`
8 }
9}
10
11export 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
18export const SERVICES_TWITTER_USERNAME_VALIDATOR: BuildFormValidator = {
19 VALIDATORS: [Validators.required],
20 MESSAGES: {
21 'required': $localize`Twitter username is required.`
22 }
23}
24
25export 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
34export 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
43export 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
52export 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
60export 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
68export const INDEX_URL_VALIDATOR: BuildFormValidator = {
69 VALIDATORS: [Validators.pattern(/^https:\/\//)],
70 MESSAGES: {
71 'pattern': $localize`Index URL should be a URL`
72 }
73}
74
75export 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}
diff --git a/client/src/app/shared/form-validators/form-validator.model.ts b/client/src/app/shared/form-validators/form-validator.model.ts
new file mode 100644
index 000000000..248a3b1d3
--- /dev/null
+++ b/client/src/app/shared/form-validators/form-validator.model.ts
@@ -0,0 +1,14 @@
1import { ValidatorFn } from '@angular/forms'
2
3export type BuildFormValidator = {
4 VALIDATORS: ValidatorFn[],
5 MESSAGES: { [ name: string ]: string }
6}
7
8export type BuildFormArgument = {
9 [ id: string ]: BuildFormValidator | BuildFormArgument
10}
11
12export type BuildFormDefaultValues = {
13 [ name: string ]: string | string[] | BuildFormDefaultValues
14}
diff --git a/client/src/app/shared/shared-forms/form-validators/host.ts b/client/src/app/shared/form-validators/host.ts
index c18a35f9b..c18a35f9b 100644
--- a/client/src/app/shared/shared-forms/form-validators/host.ts
+++ b/client/src/app/shared/form-validators/host.ts
diff --git a/client/src/app/shared/form-validators/index.ts b/client/src/app/shared/form-validators/index.ts
new file mode 100644
index 000000000..f621f03a4
--- /dev/null
+++ b/client/src/app/shared/form-validators/index.ts
@@ -0,0 +1,17 @@
1export * from './form-validator.model'
2export * from './host'
3
4// Don't re export const variables because webpack 4 cannot do tree shaking with them
5// export * from './abuse-validators'
6// export * from './batch-domains-validators'
7// export * from './custom-config-validators'
8// export * from './instance-validators'
9// export * from './login-validators'
10// export * from './reset-password-validators'
11// export * from './user-validators'
12// export * from './video-block-validators'
13// export * from './video-captions-validators'
14// export * from './video-channel-validators'
15// export * from './video-comment-validators'
16// export * from './video-playlist-validators'
17// export * from './video-validators'
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 @@
1import { Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3
4export 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
12export 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
25export 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
38export 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}
diff --git a/client/src/app/shared/form-validators/login-validators.ts b/client/src/app/shared/form-validators/login-validators.ts
new file mode 100644
index 000000000..1ceae1be3
--- /dev/null
+++ b/client/src/app/shared/form-validators/login-validators.ts
@@ -0,0 +1,20 @@
1import { Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3
4export const LOGIN_USERNAME_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [
6 Validators.required
7 ],
8 MESSAGES: {
9 'required': $localize`Username is required.`
10 }
11}
12
13export const LOGIN_PASSWORD_VALIDATOR: BuildFormValidator = {
14 VALIDATORS: [
15 Validators.required
16 ],
17 MESSAGES: {
18 'required': $localize`Password is required.`
19 }
20}
diff --git a/client/src/app/shared/form-validators/reset-password-validators.ts b/client/src/app/shared/form-validators/reset-password-validators.ts
new file mode 100644
index 000000000..b87f2eab9
--- /dev/null
+++ b/client/src/app/shared/form-validators/reset-password-validators.ts
@@ -0,0 +1,11 @@
1import { Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3
4export const RESET_PASSWORD_CONFIRM_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [
6 Validators.required
7 ],
8 MESSAGES: {
9 'required': $localize`Confirmation of the password is required.`
10 }
11}
diff --git a/client/src/app/shared/form-validators/user-validators.ts b/client/src/app/shared/form-validators/user-validators.ts
new file mode 100644
index 000000000..18199505c
--- /dev/null
+++ b/client/src/app/shared/form-validators/user-validators.ts
@@ -0,0 +1,144 @@
1import { Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3
4export const USER_USERNAME_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [
6 Validators.required,
7 Validators.minLength(1),
8 Validators.maxLength(50),
9 Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
10 ],
11 MESSAGES: {
12 'required': $localize`Username is required.`,
13 'minlength': $localize`Username must be at least 1 character long.`,
14 'maxlength': $localize`Username cannot be more than 50 characters long.`,
15 'pattern': $localize`Username should be lowercase alphanumeric; dots and underscores are allowed.`
16 }
17}
18
19export const USER_CHANNEL_NAME_VALIDATOR: BuildFormValidator = {
20 VALIDATORS: [
21 Validators.required,
22 Validators.minLength(1),
23 Validators.maxLength(50),
24 Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
25 ],
26 MESSAGES: {
27 'required': $localize`Channel name is required.`,
28 'minlength': $localize`Channel name must be at least 1 character long.`,
29 'maxlength': $localize`Channel name cannot be more than 50 characters long.`,
30 'pattern': $localize`Channel name should be lowercase alphanumeric; dots and underscores are allowed.`
31 }
32}
33
34export const USER_EMAIL_VALIDATOR: BuildFormValidator = {
35 VALIDATORS: [ Validators.required, Validators.email ],
36 MESSAGES: {
37 'required': $localize`Email is required.`,
38 'email': $localize`Email must be valid.`
39 }
40}
41
42export const USER_PASSWORD_VALIDATOR: BuildFormValidator = {
43 VALIDATORS: [
44 Validators.required,
45 Validators.minLength(6),
46 Validators.maxLength(255)
47 ],
48 MESSAGES: {
49 'required': $localize`Password is required.`,
50 'minlength': $localize`Password must be at least 6 characters long.`,
51 'maxlength': $localize`Password cannot be more than 255 characters long.`
52 }
53}
54
55export const USER_PASSWORD_OPTIONAL_VALIDATOR: BuildFormValidator = {
56 VALIDATORS: [
57 Validators.minLength(6),
58 Validators.maxLength(255)
59 ],
60 MESSAGES: {
61 'minlength': $localize`Password must be at least 6 characters long.`,
62 'maxlength': $localize`Password cannot be more than 255 characters long.`
63 }
64}
65
66export const USER_CONFIRM_PASSWORD_VALIDATOR: BuildFormValidator = {
67 VALIDATORS: [],
68 MESSAGES: {
69 'matchPassword': $localize`The new password and the confirmed password do not correspond.`
70 }
71}
72
73export const USER_VIDEO_QUOTA_VALIDATOR: BuildFormValidator = {
74 VALIDATORS: [ Validators.required, Validators.min(-1) ],
75 MESSAGES: {
76 'required': $localize`Video quota is required.`,
77 'min': $localize`Quota must be greater than -1.`
78 }
79}
80export const USER_VIDEO_QUOTA_DAILY_VALIDATOR: BuildFormValidator = {
81 VALIDATORS: [ Validators.required, Validators.min(-1) ],
82 MESSAGES: {
83 'required': $localize`Daily upload limit is required.`,
84 'min': $localize`Daily upload limit must be greater than -1.`
85 }
86}
87
88export const USER_ROLE_VALIDATOR: BuildFormValidator = {
89 VALIDATORS: [ Validators.required ],
90 MESSAGES: {
91 'required': $localize`User role is required.`
92 }
93}
94
95export const USER_DISPLAY_NAME_REQUIRED_VALIDATOR = buildDisplayNameValidator(true)
96
97export const USER_DESCRIPTION_VALIDATOR: BuildFormValidator = {
98 VALIDATORS: [
99 Validators.minLength(3),
100 Validators.maxLength(1000)
101 ],
102 MESSAGES: {
103 'minlength': $localize`Description must be at least 3 characters long.`,
104 'maxlength': $localize`Description cannot be more than 1000 characters long.`
105 }
106}
107
108export const USER_TERMS_VALIDATOR: BuildFormValidator = {
109 VALIDATORS: [
110 Validators.requiredTrue
111 ],
112 MESSAGES: {
113 'required': $localize`You must agree with the instance terms in order to register on it.`
114 }
115}
116
117export const USER_BAN_REASON_VALIDATOR: BuildFormValidator = {
118 VALIDATORS: [
119 Validators.minLength(3),
120 Validators.maxLength(250)
121 ],
122 MESSAGES: {
123 'minlength': $localize`Ban reason must be at least 3 characters long.`,
124 'maxlength': $localize`Ban reason cannot be more than 250 characters long.`
125 }
126}
127
128function buildDisplayNameValidator (required: boolean) {
129 const control = {
130 VALIDATORS: [
131 Validators.minLength(1),
132 Validators.maxLength(120)
133 ],
134 MESSAGES: {
135 'required': $localize`Display name is required.`,
136 'minlength': $localize`Display name must be at least 1 character long.`,
137 'maxlength': $localize`Display name cannot be more than 50 characters long.`
138 }
139 }
140
141 if (required) control.VALIDATORS.push(Validators.required)
142
143 return control
144}
diff --git a/client/src/app/shared/form-validators/video-block-validators.ts b/client/src/app/shared/form-validators/video-block-validators.ts
new file mode 100644
index 000000000..d3974aefe
--- /dev/null
+++ b/client/src/app/shared/form-validators/video-block-validators.ts
@@ -0,0 +1,10 @@
1import { Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3
4export const VIDEO_BLOCK_REASON_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [ Validators.minLength(2), Validators.maxLength(300) ],
6 MESSAGES: {
7 'minlength': $localize`Block reason must be at least 2 characters long.`,
8 'maxlength': $localize`Block reason cannot be more than 300 characters long.`
9 }
10}
diff --git a/client/src/app/shared/form-validators/video-captions-validators.ts b/client/src/app/shared/form-validators/video-captions-validators.ts
new file mode 100644
index 000000000..9742d2925
--- /dev/null
+++ b/client/src/app/shared/form-validators/video-captions-validators.ts
@@ -0,0 +1,16 @@
1import { Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3
4export const VIDEO_CAPTION_LANGUAGE_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [ Validators.required ],
6 MESSAGES: {
7 'required': $localize`Video caption language is required.`
8 }
9}
10
11export const VIDEO_CAPTION_FILE_VALIDATOR: BuildFormValidator = {
12 VALIDATORS: [ Validators.required ],
13 MESSAGES: {
14 'required': $localize`Video caption file is required.`
15 }
16}
diff --git a/client/src/app/shared/form-validators/video-channel-validators.ts b/client/src/app/shared/form-validators/video-channel-validators.ts
new file mode 100644
index 000000000..0daab22ce
--- /dev/null
+++ b/client/src/app/shared/form-validators/video-channel-validators.ts
@@ -0,0 +1,52 @@
1import { Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3
4export const VIDEO_CHANNEL_NAME_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [
6 Validators.required,
7 Validators.minLength(1),
8 Validators.maxLength(50),
9 Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
10 ],
11 MESSAGES: {
12 'required': $localize`Name is required.`,
13 'minlength': $localize`Name must be at least 1 character long.`,
14 'maxlength': $localize`Name cannot be more than 50 characters long.`,
15 'pattern': $localize`Name should be lowercase alphanumeric; dots and underscores are allowed.`
16 }
17}
18
19export const VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR: BuildFormValidator = {
20 VALIDATORS: [
21 Validators.required,
22 Validators.minLength(1),
23 Validators.maxLength(50)
24 ],
25 MESSAGES: {
26 'required': $localize`Display name is required.`,
27 'minlength': $localize`Display name must be at least 1 character long.`,
28 'maxlength': $localize`Display name cannot be more than 50 characters long.`
29 }
30}
31
32export const VIDEO_CHANNEL_DESCRIPTION_VALIDATOR: BuildFormValidator = {
33 VALIDATORS: [
34 Validators.minLength(3),
35 Validators.maxLength(1000)
36 ],
37 MESSAGES: {
38 'minlength': $localize`Description must be at least 3 characters long.`,
39 'maxlength': $localize`Description cannot be more than 1000 characters long.`
40 }
41}
42
43export const VIDEO_CHANNEL_SUPPORT_VALIDATOR: BuildFormValidator = {
44 VALIDATORS: [
45 Validators.minLength(3),
46 Validators.maxLength(1000)
47 ],
48 MESSAGES: {
49 'minlength': $localize`Support text must be at least 3 characters long.`,
50 'maxlength': $localize`Support text cannot be more than 1000 characters long`
51 }
52}
diff --git a/client/src/app/shared/form-validators/video-comment-validators.ts b/client/src/app/shared/form-validators/video-comment-validators.ts
new file mode 100644
index 000000000..c56564d34
--- /dev/null
+++ b/client/src/app/shared/form-validators/video-comment-validators.ts
@@ -0,0 +1,11 @@
1import { Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3
4export const VIDEO_COMMENT_TEXT_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [ Validators.required, Validators.minLength(1), Validators.maxLength(3000) ],
6 MESSAGES: {
7 'required': $localize`Comment is required.`,
8 'minlength': $localize`Comment must be at least 2 characters long.`,
9 'maxlength': $localize`Comment cannot be more than 3000 characters long.`
10 }
11}
diff --git a/client/src/app/shared/form-validators/video-ownership-change-validators.ts b/client/src/app/shared/form-validators/video-ownership-change-validators.ts
new file mode 100644
index 000000000..e1a2df8a6
--- /dev/null
+++ b/client/src/app/shared/form-validators/video-ownership-change-validators.ts
@@ -0,0 +1,25 @@
1import { AbstractControl, ValidationErrors, Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3
4export const OWNERSHIP_CHANGE_CHANNEL_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [ Validators.required ],
6 MESSAGES: {
7 'required': $localize`The channel is required.`
8 }
9}
10
11export const OWNERSHIP_CHANGE_USERNAME_VALIDATOR: BuildFormValidator = {
12 VALIDATORS: [ Validators.required, localAccountValidator ],
13 MESSAGES: {
14 'required': $localize`The username is required.`,
15 'localAccountOnly': $localize`You can only transfer ownership to a local account`
16 }
17}
18
19function localAccountValidator (control: AbstractControl): ValidationErrors {
20 if (control.value.includes('@')) {
21 return { 'localAccountOnly': true }
22 }
23
24 return null
25}
diff --git a/client/src/app/shared/form-validators/video-playlist-validators.ts b/client/src/app/shared/form-validators/video-playlist-validators.ts
new file mode 100644
index 000000000..7e3d29458
--- /dev/null
+++ b/client/src/app/shared/form-validators/video-playlist-validators.ts
@@ -0,0 +1,54 @@
1import { Validators, AbstractControl } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3import { VideoPlaylistPrivacy } from '@shared/models'
4
5export const VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR: BuildFormValidator = {
6 VALIDATORS: [
7 Validators.required,
8 Validators.minLength(1),
9 Validators.maxLength(120)
10 ],
11 MESSAGES: {
12 'required': $localize`Display name is required.`,
13 'minlength': $localize`Display name must be at least 1 character long.`,
14 'maxlength': $localize`Display name cannot be more than 120 characters long.`
15 }
16}
17
18export const VIDEO_PLAYLIST_PRIVACY_VALIDATOR: BuildFormValidator = {
19 VALIDATORS: [
20 Validators.required
21 ],
22 MESSAGES: {
23 'required': $localize`Privacy is required.`
24 }
25}
26
27export const VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR: BuildFormValidator = {
28 VALIDATORS: [
29 Validators.minLength(3),
30 Validators.maxLength(1000)
31 ],
32 MESSAGES: {
33 'minlength': $localize`Description must be at least 3 characters long.`,
34 'maxlength': $localize`Description cannot be more than 1000 characters long.`
35 }
36}
37
38export const VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR: BuildFormValidator = {
39 VALIDATORS: [],
40 MESSAGES: {
41 'required': $localize`The channel is required when the playlist is public.`
42 }
43}
44
45export function setPlaylistChannelValidator (channelControl: AbstractControl, privacy: VideoPlaylistPrivacy) {
46 if (privacy.toString() === VideoPlaylistPrivacy.PUBLIC.toString()) {
47 channelControl.setValidators([Validators.required])
48 } else {
49 channelControl.setValidators(null)
50 }
51
52 channelControl.markAsDirty()
53 channelControl.updateValueAndValidity()
54}
diff --git a/client/src/app/shared/form-validators/video-validators.ts b/client/src/app/shared/form-validators/video-validators.ts
new file mode 100644
index 000000000..23f2391b2
--- /dev/null
+++ b/client/src/app/shared/form-validators/video-validators.ts
@@ -0,0 +1,101 @@
1import { AbstractControl, ValidationErrors, ValidatorFn, Validators } from '@angular/forms'
2import { BuildFormValidator } from './form-validator.model'
3
4export const VIDEO_NAME_VALIDATOR: BuildFormValidator = {
5 VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ],
6 MESSAGES: {
7 'required': $localize`Video name is required.`,
8 'minlength': $localize`Video name must be at least 3 characters long.`,
9 'maxlength': $localize`Video name cannot be more than 120 characters long.`
10 }
11}
12
13export const VIDEO_PRIVACY_VALIDATOR: BuildFormValidator = {
14 VALIDATORS: [ Validators.required ],
15 MESSAGES: {
16 'required': $localize`Video privacy is required.`
17 }
18}
19
20export const VIDEO_CATEGORY_VALIDATOR: BuildFormValidator = {
21 VALIDATORS: [ ],
22 MESSAGES: {}
23}
24
25export const VIDEO_LICENCE_VALIDATOR: BuildFormValidator = {
26 VALIDATORS: [ ],
27 MESSAGES: {}
28}
29
30export const VIDEO_LANGUAGE_VALIDATOR: BuildFormValidator = {
31 VALIDATORS: [ ],
32 MESSAGES: {}
33}
34
35export const VIDEO_IMAGE_VALIDATOR: BuildFormValidator = {
36 VALIDATORS: [ ],
37 MESSAGES: {}
38}
39
40export const VIDEO_CHANNEL_VALIDATOR: BuildFormValidator = {
41 VALIDATORS: [ Validators.required ],
42 MESSAGES: {
43 'required': $localize`Video channel is required.`
44 }
45}
46
47export const VIDEO_DESCRIPTION_VALIDATOR: BuildFormValidator = {
48 VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ],
49 MESSAGES: {
50 'minlength': $localize`Video description must be at least 3 characters long.`,
51 'maxlength': $localize`Video description cannot be more than 10000 characters long.`
52 }
53}
54
55export const VIDEO_TAG_VALIDATOR: BuildFormValidator = {
56 VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ],
57 MESSAGES: {
58 'minlength': $localize`A tag should be more than 2 characters long.`,
59 'maxlength': $localize`A tag should be less than 30 characters long.`
60 }
61}
62
63export const VIDEO_TAGS_ARRAY_VALIDATOR: BuildFormValidator = {
64 VALIDATORS: [ Validators.maxLength(5), arrayTagLengthValidator() ],
65 MESSAGES: {
66 'maxlength': $localize`A maximum of 5 tags can be used on a video.`,
67 'arrayTagLength': $localize`A tag should be more than 2, and less than 30 characters long.`
68 }
69}
70
71export const VIDEO_SUPPORT_VALIDATOR: BuildFormValidator = {
72 VALIDATORS: [ Validators.minLength(3), Validators.maxLength(1000) ],
73 MESSAGES: {
74 'minlength': $localize`Video support must be at least 3 characters long.`,
75 'maxlength': $localize`Video support cannot be more than 1000 characters long.`
76 }
77}
78
79export const VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR: BuildFormValidator = {
80 VALIDATORS: [ ],
81 MESSAGES: {
82 'required': $localize`A date is required to schedule video update.`
83 }
84}
85
86export const VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR: BuildFormValidator = {
87 VALIDATORS: [ ],
88 MESSAGES: {}
89}
90
91function arrayTagLengthValidator (min = 2, max = 30): ValidatorFn {
92 return (control: AbstractControl): ValidationErrors => {
93 const array = control.value as Array<string>
94
95 if (array.every(e => e.length > min && e.length < max)) {
96 return null
97 }
98
99 return { 'arrayTagLength': true }
100 }
101}
diff --git a/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts b/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts
index 0c3c8ff48..9abb4c094 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts
+++ b/client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts
@@ -1,9 +1,10 @@
1import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' 1import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
2import { AuthService, HtmlRendererService, Notifier } from '@app/core' 2import { AuthService, HtmlRendererService, Notifier } from '@app/core'
3import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms' 3import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
4import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 4import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
5import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 5import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
6import { AbuseMessage, UserAbuse } from '@shared/models' 6import { AbuseMessage, UserAbuse } from '@shared/models'
7import { ABUSE_MESSAGE_VALIDATOR } from '../form-validators/abuse-validators'
7import { AbuseService } from '../shared-moderation' 8import { AbuseService } from '../shared-moderation'
8 9
9@Component({ 10@Component({
@@ -28,7 +29,6 @@ export class AbuseMessageModalComponent extends FormReactive implements OnInit {
28 29
29 constructor ( 30 constructor (
30 protected formValidatorService: FormValidatorService, 31 protected formValidatorService: FormValidatorService,
31 private abuseValidatorsService: AbuseValidatorsService,
32 private modalService: NgbModal, 32 private modalService: NgbModal,
33 private htmlRenderer: HtmlRendererService, 33 private htmlRenderer: HtmlRendererService,
34 private auth: AuthService, 34 private auth: AuthService,
@@ -40,7 +40,7 @@ export class AbuseMessageModalComponent extends FormReactive implements OnInit {
40 40
41 ngOnInit () { 41 ngOnInit () {
42 this.buildForm({ 42 this.buildForm({
43 message: this.abuseValidatorsService.ABUSE_MESSAGE 43 message: ABUSE_MESSAGE_VALIDATOR
44 }) 44 })
45 } 45 }
46 46
diff --git a/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts b/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts
index fad7f888d..876aeea8a 100644
--- a/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts
+++ b/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts
@@ -1,10 +1,11 @@
1import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' 1import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
2import { Notifier } from '@app/core' 2import { Notifier } from '@app/core'
3import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms' 3import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
4import { AbuseService } from '@app/shared/shared-moderation' 4import { AbuseService } from '@app/shared/shared-moderation'
5import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 5import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
6import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 6import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
7import { AdminAbuse } from '@shared/models' 7import { AdminAbuse } from '@shared/models'
8import { ABUSE_MODERATION_COMMENT_VALIDATOR } from '../form-validators/abuse-validators'
8 9
9@Component({ 10@Component({
10 selector: 'my-moderation-comment-modal', 11 selector: 'my-moderation-comment-modal',
@@ -22,15 +23,14 @@ export class ModerationCommentModalComponent extends FormReactive implements OnI
22 protected formValidatorService: FormValidatorService, 23 protected formValidatorService: FormValidatorService,
23 private modalService: NgbModal, 24 private modalService: NgbModal,
24 private notifier: Notifier, 25 private notifier: Notifier,
25 private abuseService: AbuseService, 26 private abuseService: AbuseService
26 private abuseValidatorsService: AbuseValidatorsService
27 ) { 27 ) {
28 super() 28 super()
29 } 29 }
30 30
31 ngOnInit () { 31 ngOnInit () {
32 this.buildForm({ 32 this.buildForm({
33 moderationComment: this.abuseValidatorsService.ABUSE_MODERATION_COMMENT 33 moderationComment: ABUSE_MODERATION_COMMENT_VALIDATOR
34 }) 34 })
35 } 35 }
36 36
diff --git a/client/src/app/shared/shared-forms/form-reactive.ts b/client/src/app/shared/shared-forms/form-reactive.ts
index caa31d831..adf6cb894 100644
--- a/client/src/app/shared/shared-forms/form-reactive.ts
+++ b/client/src/app/shared/shared-forms/form-reactive.ts
@@ -1,5 +1,6 @@
1import { FormGroup } from '@angular/forms' 1import { FormGroup } from '@angular/forms'
2import { BuildFormArgument, BuildFormDefaultValues, FormValidatorService } from './form-validators' 2import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model'
3import { FormValidatorService } from './form-validator.service'
3 4
4export type FormReactiveErrors = { [ id: string ]: string | FormReactiveErrors } 5export type FormReactiveErrors = { [ id: string ]: string | FormReactiveErrors }
5export type FormReactiveValidationMessages = { 6export type FormReactiveValidationMessages = {
diff --git a/client/src/app/shared/shared-forms/form-validators/form-validator.service.ts b/client/src/app/shared/shared-forms/form-validator.service.ts
index dec7d8d9a..41c8b76bd 100644
--- a/client/src/app/shared/shared-forms/form-validators/form-validator.service.ts
+++ b/client/src/app/shared/shared-forms/form-validator.service.ts
@@ -1,17 +1,7 @@
1import { FormBuilder, FormControl, FormGroup, ValidatorFn } from '@angular/forms'
2import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
3import { FormReactiveErrors, FormReactiveValidationMessages } from '../form-reactive' 2import { FormBuilder, FormControl, FormGroup, ValidatorFn } from '@angular/forms'
4 3import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model'
5export type BuildFormValidator = { 4import { FormReactiveErrors, FormReactiveValidationMessages } from './form-reactive'
6 VALIDATORS: ValidatorFn[],
7 MESSAGES: { [ name: string ]: string }
8}
9export type BuildFormArgument = {
10 [ id: string ]: BuildFormValidator | BuildFormArgument
11}
12export type BuildFormDefaultValues = {
13 [ name: string ]: string | string[] | BuildFormDefaultValues
14}
15 5
16@Injectable() 6@Injectable()
17export class FormValidatorService { 7export class FormValidatorService {
diff --git a/client/src/app/shared/shared-forms/form-validators/abuse-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/abuse-validators.service.ts
deleted file mode 100644
index 56d30d6f9..000000000
--- a/client/src/app/shared/shared-forms/form-validators/abuse-validators.service.ts
+++ /dev/null
@@ -1,39 +0,0 @@
1import { Injectable } from '@angular/core'
2import { Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service'
4
5@Injectable()
6export class AbuseValidatorsService {
7 readonly ABUSE_REASON: BuildFormValidator
8 readonly ABUSE_MODERATION_COMMENT: BuildFormValidator
9 readonly ABUSE_MESSAGE: BuildFormValidator
10
11 constructor () {
12 this.ABUSE_REASON = {
13 VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
14 MESSAGES: {
15 'required': $localize`Report reason is required.`,
16 'minlength': $localize`Report reason must be at least 2 characters long.`,
17 'maxlength': $localize`Report reason cannot be more than 3000 characters long.`
18 }
19 }
20
21 this.ABUSE_MODERATION_COMMENT = {
22 VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
23 MESSAGES: {
24 'required': $localize`Moderation comment is required.`,
25 'minlength': $localize`Moderation comment must be at least 2 characters long.`,
26 'maxlength': $localize`Moderation comment cannot be more than 3000 characters long.`
27 }
28 }
29
30 this.ABUSE_MESSAGE = {
31 VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
32 MESSAGES: {
33 'required': $localize`Abuse message is required.`,
34 'minlength': $localize`Abuse message must be at least 2 characters long.`,
35 'maxlength': $localize`Abuse message cannot be more than 3000 characters long.`
36 }
37 }
38 }
39}
diff --git a/client/src/app/shared/shared-forms/form-validators/batch-domains-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/batch-domains-validators.service.ts
deleted file mode 100644
index 6c7da833f..000000000
--- a/client/src/app/shared/shared-forms/form-validators/batch-domains-validators.service.ts
+++ /dev/null
@@ -1,68 +0,0 @@
1import { Injectable } from '@angular/core'
2import { ValidatorFn, Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service'
4import { validateHost } from './host'
5
6@Injectable()
7export class BatchDomainsValidatorsService {
8 readonly DOMAINS: BuildFormValidator
9
10 constructor () {
11 this.DOMAINS = {
12 VALIDATORS: [ Validators.required, this.validDomains, this.isHostsUnique ],
13 MESSAGES: {
14 'required': $localize`Domain is required.`,
15 'validDomains': $localize`Domains entered are invalid.`,
16 'uniqueDomains': $localize`Domains entered contain duplicates.`
17 }
18 }
19 }
20
21 getNotEmptyHosts (hosts: string) {
22 return hosts
23 .split('\n')
24 .filter((host: string) => host && host.length !== 0) // Eject empty hosts
25 }
26
27 private validDomains: ValidatorFn = (control) => {
28 if (!control.value) return null
29
30 const newHostsErrors = []
31 const hosts = this.getNotEmptyHosts(control.value)
32
33 for (const host of hosts) {
34 if (validateHost(host) === false) {
35 newHostsErrors.push($localize`${host} is not valid`)
36 }
37 }
38
39 /* Is not valid. */
40 if (newHostsErrors.length !== 0) {
41 return {
42 'validDomains': {
43 reason: 'invalid',
44 value: newHostsErrors.join('. ') + '.'
45 }
46 }
47 }
48
49 /* Is valid. */
50 return null
51 }
52
53 private isHostsUnique: ValidatorFn = (control) => {
54 if (!control.value) return null
55
56 const hosts = this.getNotEmptyHosts(control.value)
57
58 if (hosts.every((host: string) => hosts.indexOf(host) === hosts.lastIndexOf(host))) {
59 return null
60 } else {
61 return {
62 'uniqueDomains': {
63 reason: 'invalid'
64 }
65 }
66 }
67 }
68}
diff --git a/client/src/app/shared/shared-forms/form-validators/custom-config-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/custom-config-validators.service.ts
deleted file mode 100644
index 862ff5470..000000000
--- a/client/src/app/shared/shared-forms/form-validators/custom-config-validators.service.ts
+++ /dev/null
@@ -1,97 +0,0 @@
1import { Injectable } from '@angular/core'
2import { Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service'
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
11 readonly CACHE_CAPTIONS_SIZE: BuildFormValidator
12 readonly SIGNUP_LIMIT: BuildFormValidator
13 readonly ADMIN_EMAIL: BuildFormValidator
14 readonly TRANSCODING_THREADS: BuildFormValidator
15 readonly INDEX_URL: BuildFormValidator
16 readonly SEARCH_INDEX_URL: BuildFormValidator
17
18 constructor () {
19 this.INSTANCE_NAME = {
20 VALIDATORS: [ Validators.required ],
21 MESSAGES: {
22 'required': $localize`Instance name is required.`
23 }
24 }
25
26 this.INSTANCE_SHORT_DESCRIPTION = {
27 VALIDATORS: [ Validators.max(250) ],
28 MESSAGES: {
29 'max': $localize`Short description should not be longer than 250 characters.`
30 }
31 }
32
33 this.SERVICES_TWITTER_USERNAME = {
34 VALIDATORS: [ Validators.required ],
35 MESSAGES: {
36 'required': $localize`Twitter username is required.`
37 }
38 }
39
40 this.CACHE_PREVIEWS_SIZE = {
41 VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
42 MESSAGES: {
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.`
46 }
47 }
48
49 this.CACHE_CAPTIONS_SIZE = {
50 VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
51 MESSAGES: {
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.`
55 }
56 }
57
58 this.SIGNUP_LIMIT = {
59 VALIDATORS: [ Validators.required, Validators.min(-1), Validators.pattern('-?[0-9]+') ],
60 MESSAGES: {
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.`
64 }
65 }
66
67 this.ADMIN_EMAIL = {
68 VALIDATORS: [ Validators.required, Validators.email ],
69 MESSAGES: {
70 'required': $localize`Admin email is required.`,
71 'email': $localize`Admin email must be valid.`
72 }
73 }
74
75 this.TRANSCODING_THREADS = {
76 VALIDATORS: [ Validators.required, Validators.min(0) ],
77 MESSAGES: {
78 'required': $localize`Transcoding threads is required.`,
79 'min': $localize`Transcoding threads must be greater or equal to 0.`
80 }
81 }
82
83 this.INDEX_URL = {
84 VALIDATORS: [ Validators.pattern(/^https:\/\//) ],
85 MESSAGES: {
86 'pattern': $localize`Index URL should be a URL`
87 }
88 }
89
90 this.SEARCH_INDEX_URL = {
91 VALIDATORS: [ Validators.pattern(/^https?:\/\//) ],
92 MESSAGES: {
93 'pattern': $localize`Search index URL should be a URL`
94 }
95 }
96 }
97}
diff --git a/client/src/app/shared/shared-forms/form-validators/index.ts b/client/src/app/shared/shared-forms/form-validators/index.ts
deleted file mode 100644
index b06a326ff..000000000
--- a/client/src/app/shared/shared-forms/form-validators/index.ts
+++ /dev/null
@@ -1,17 +0,0 @@
1export * from './abuse-validators.service'
2export * from './batch-domains-validators.service'
3export * from './custom-config-validators.service'
4export * from './form-validator.service'
5export * from './host'
6export * from './instance-validators.service'
7export * from './login-validators.service'
8export * from './reset-password-validators.service'
9export * from './user-validators.service'
10export * from './video-accept-ownership-validators.service'
11export * from './video-block-validators.service'
12export * from './video-captions-validators.service'
13export * from './video-change-ownership-validators.service'
14export * from './video-channel-validators.service'
15export * from './video-comment-validators.service'
16export * from './video-playlist-validators.service'
17export * from './video-validators.service'
diff --git a/client/src/app/shared/shared-forms/form-validators/instance-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/instance-validators.service.ts
deleted file mode 100644
index 3628f0b60..000000000
--- a/client/src/app/shared/shared-forms/form-validators/instance-validators.service.ts
+++ /dev/null
@@ -1,61 +0,0 @@
1import { Injectable } from '@angular/core'
2import { Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service'
4
5@Injectable()
6export class InstanceValidatorsService {
7 readonly FROM_EMAIL: BuildFormValidator
8 readonly FROM_NAME: BuildFormValidator
9 readonly SUBJECT: BuildFormValidator
10 readonly BODY: BuildFormValidator
11
12 constructor () {
13
14 this.FROM_EMAIL = {
15 VALIDATORS: [ Validators.required, Validators.email ],
16 MESSAGES: {
17 'required': $localize`Email is required.`,
18 'email': $localize`Email must be valid.`
19 }
20 }
21
22 this.FROM_NAME = {
23 VALIDATORS: [
24 Validators.required,
25 Validators.minLength(1),
26 Validators.maxLength(120)
27 ],
28 MESSAGES: {
29 'required': $localize`Your name is required.`,
30 'minlength': $localize`Your name must be at least 1 character long.`,
31 'maxlength': $localize`Your name cannot be more than 120 characters long.`
32 }
33 }
34
35 this.SUBJECT = {
36 VALIDATORS: [
37 Validators.required,
38 Validators.minLength(1),
39 Validators.maxLength(120)
40 ],
41 MESSAGES: {
42 'required': $localize`A subject is required.`,
43 'minlength': $localize`The subject must be at least 1 character long.`,
44 'maxlength': $localize`The subject cannot be more than 120 characters long.`
45 }
46 }
47
48 this.BODY = {
49 VALIDATORS: [
50 Validators.required,
51 Validators.minLength(3),
52 Validators.maxLength(5000)
53 ],
54 MESSAGES: {
55 'required': $localize`A message is required.`,
56 'minlength': $localize`The message must be at least 3 characters long.`,
57 'maxlength': $localize`The message cannot be more than 5000 characters long.`
58 }
59 }
60 }
61}
diff --git a/client/src/app/shared/shared-forms/form-validators/login-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/login-validators.service.ts
deleted file mode 100644
index 67ea11f20..000000000
--- a/client/src/app/shared/shared-forms/form-validators/login-validators.service.ts
+++ /dev/null
@@ -1,29 +0,0 @@
1import { Injectable } from '@angular/core'
2import { Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service'
4
5@Injectable()
6export class LoginValidatorsService {
7 readonly LOGIN_USERNAME: BuildFormValidator
8 readonly LOGIN_PASSWORD: BuildFormValidator
9
10 constructor () {
11 this.LOGIN_USERNAME = {
12 VALIDATORS: [
13 Validators.required
14 ],
15 MESSAGES: {
16 'required': $localize`Username is required.`
17 }
18 }
19
20 this.LOGIN_PASSWORD = {
21 VALIDATORS: [
22 Validators.required
23 ],
24 MESSAGES: {
25 'required': $localize`Password is required.`
26 }
27 }
28 }
29}
diff --git a/client/src/app/shared/shared-forms/form-validators/reset-password-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/reset-password-validators.service.ts
deleted file mode 100644
index 3d0b4dd64..000000000
--- a/client/src/app/shared/shared-forms/form-validators/reset-password-validators.service.ts
+++ /dev/null
@@ -1,19 +0,0 @@
1import { Injectable } from '@angular/core'
2import { Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service'
4
5@Injectable()
6export class ResetPasswordValidatorsService {
7 readonly RESET_PASSWORD_CONFIRM: BuildFormValidator
8
9 constructor () {
10 this.RESET_PASSWORD_CONFIRM = {
11 VALIDATORS: [
12 Validators.required
13 ],
14 MESSAGES: {
15 'required': $localize`Confirmation of the password is required.`
16 }
17 }
18 }
19}
diff --git a/client/src/app/shared/shared-forms/form-validators/user-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/user-validators.service.ts
deleted file mode 100644
index 312fc9b1e..000000000
--- a/client/src/app/shared/shared-forms/form-validators/user-validators.service.ts
+++ /dev/null
@@ -1,166 +0,0 @@
1import { Injectable } from '@angular/core'
2import { Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service'
4
5@Injectable()
6export class UserValidatorsService {
7 readonly USER_USERNAME: BuildFormValidator
8 readonly USER_CHANNEL_NAME: BuildFormValidator
9 readonly USER_EMAIL: BuildFormValidator
10 readonly USER_PASSWORD: BuildFormValidator
11 readonly USER_PASSWORD_OPTIONAL: BuildFormValidator
12 readonly USER_CONFIRM_PASSWORD: BuildFormValidator
13 readonly USER_VIDEO_QUOTA: BuildFormValidator
14 readonly USER_VIDEO_QUOTA_DAILY: BuildFormValidator
15 readonly USER_ROLE: BuildFormValidator
16 readonly USER_DISPLAY_NAME_REQUIRED: BuildFormValidator
17 readonly USER_DESCRIPTION: BuildFormValidator
18 readonly USER_TERMS: BuildFormValidator
19
20 readonly USER_BAN_REASON: BuildFormValidator
21
22 constructor () {
23
24 this.USER_USERNAME = {
25 VALIDATORS: [
26 Validators.required,
27 Validators.minLength(1),
28 Validators.maxLength(50),
29 Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
30 ],
31 MESSAGES: {
32 'required': $localize`Username is required.`,
33 'minlength': $localize`Username must be at least 1 character long.`,
34 'maxlength': $localize`Username cannot be more than 50 characters long.`,
35 'pattern': $localize`Username should be lowercase alphanumeric; dots and underscores are allowed.`
36 }
37 }
38
39 this.USER_CHANNEL_NAME = {
40 VALIDATORS: [
41 Validators.required,
42 Validators.minLength(1),
43 Validators.maxLength(50),
44 Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
45 ],
46 MESSAGES: {
47 'required': $localize`Channel name is required.`,
48 'minlength': $localize`Channel name must be at least 1 character long.`,
49 'maxlength': $localize`Channel name cannot be more than 50 characters long.`,
50 'pattern': $localize`Channel name should be lowercase alphanumeric; dots and underscores are allowed.`
51 }
52 }
53
54 this.USER_EMAIL = {
55 VALIDATORS: [ Validators.required, Validators.email ],
56 MESSAGES: {
57 'required': $localize`Email is required.`,
58 'email': $localize`Email must be valid.`
59 }
60 }
61
62 this.USER_PASSWORD = {
63 VALIDATORS: [
64 Validators.required,
65 Validators.minLength(6),
66 Validators.maxLength(255)
67 ],
68 MESSAGES: {
69 'required': $localize`Password is required.`,
70 'minlength': $localize`Password must be at least 6 characters long.`,
71 'maxlength': $localize`Password cannot be more than 255 characters long.`
72 }
73 }
74
75 this.USER_PASSWORD_OPTIONAL = {
76 VALIDATORS: [
77 Validators.minLength(6),
78 Validators.maxLength(255)
79 ],
80 MESSAGES: {
81 'minlength': $localize`Password must be at least 6 characters long.`,
82 'maxlength': $localize`Password cannot be more than 255 characters long.`
83 }
84 }
85
86 this.USER_CONFIRM_PASSWORD = {
87 VALIDATORS: [],
88 MESSAGES: {
89 'matchPassword': $localize`The new password and the confirmed password do not correspond.`
90 }
91 }
92
93 this.USER_VIDEO_QUOTA = {
94 VALIDATORS: [ Validators.required, Validators.min(-1) ],
95 MESSAGES: {
96 'required': $localize`Video quota is required.`,
97 'min': $localize`Quota must be greater than -1.`
98 }
99 }
100 this.USER_VIDEO_QUOTA_DAILY = {
101 VALIDATORS: [ Validators.required, Validators.min(-1) ],
102 MESSAGES: {
103 'required': $localize`Daily upload limit is required.`,
104 'min': $localize`Daily upload limit must be greater than -1.`
105 }
106 }
107
108 this.USER_ROLE = {
109 VALIDATORS: [ Validators.required ],
110 MESSAGES: {
111 'required': $localize`User role is required.`
112 }
113 }
114
115 this.USER_DISPLAY_NAME_REQUIRED = this.getDisplayName(true)
116
117 this.USER_DESCRIPTION = {
118 VALIDATORS: [
119 Validators.minLength(3),
120 Validators.maxLength(1000)
121 ],
122 MESSAGES: {
123 'minlength': $localize`Description must be at least 3 characters long.`,
124 'maxlength': $localize`Description cannot be more than 1000 characters long.`
125 }
126 }
127
128 this.USER_TERMS = {
129 VALIDATORS: [
130 Validators.requiredTrue
131 ],
132 MESSAGES: {
133 'required': $localize`You must agree with the instance terms in order to register on it.`
134 }
135 }
136
137 this.USER_BAN_REASON = {
138 VALIDATORS: [
139 Validators.minLength(3),
140 Validators.maxLength(250)
141 ],
142 MESSAGES: {
143 'minlength': $localize`Ban reason must be at least 3 characters long.`,
144 'maxlength': $localize`Ban reason cannot be more than 250 characters long.`
145 }
146 }
147 }
148
149 private getDisplayName (required: boolean) {
150 const control = {
151 VALIDATORS: [
152 Validators.minLength(1),
153 Validators.maxLength(120)
154 ],
155 MESSAGES: {
156 'required': $localize`Display name is required.`,
157 'minlength': $localize`Display name must be at least 1 character long.`,
158 'maxlength': $localize`Display name cannot be more than 50 characters long.`
159 }
160 }
161
162 if (required) control.VALIDATORS.push(Validators.required)
163
164 return control
165 }
166}
diff --git a/client/src/app/shared/shared-forms/form-validators/video-accept-ownership-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-accept-ownership-validators.service.ts
deleted file mode 100644
index aed9e9cdd..000000000
--- a/client/src/app/shared/shared-forms/form-validators/video-accept-ownership-validators.service.ts
+++ /dev/null
@@ -1,17 +0,0 @@
1import { Injectable } from '@angular/core'
2import { Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service'
4
5@Injectable()
6export class VideoAcceptOwnershipValidatorsService {
7 readonly CHANNEL: BuildFormValidator
8
9 constructor () {
10 this.CHANNEL = {
11 VALIDATORS: [ Validators.required ],
12 MESSAGES: {
13 'required': $localize`The channel is required.`
14 }
15 }
16 }
17}
diff --git a/client/src/app/shared/shared-forms/form-validators/video-block-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-block-validators.service.ts
deleted file mode 100644
index bce1880dc..000000000
--- a/client/src/app/shared/shared-forms/form-validators/video-block-validators.service.ts
+++ /dev/null
@@ -1,18 +0,0 @@
1import { Injectable } from '@angular/core'
2import { Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service'
4
5@Injectable()
6export class VideoBlockValidatorsService {
7 readonly VIDEO_BLOCK_REASON: BuildFormValidator
8
9 constructor () {
10 this.VIDEO_BLOCK_REASON = {
11 VALIDATORS: [ Validators.minLength(2), Validators.maxLength(300) ],
12 MESSAGES: {
13 'minlength': $localize`Block reason must be at least 2 characters long.`,
14 'maxlength': $localize`Block reason cannot be more than 300 characters long.`
15 }
16 }
17 }
18}
diff --git a/client/src/app/shared/shared-forms/form-validators/video-captions-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-captions-validators.service.ts
deleted file mode 100644
index 7e90264e5..000000000
--- a/client/src/app/shared/shared-forms/form-validators/video-captions-validators.service.ts
+++ /dev/null
@@ -1,26 +0,0 @@
1import { Injectable } from '@angular/core'
2import { Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service'
4
5@Injectable()
6export class VideoCaptionsValidatorsService {
7 readonly VIDEO_CAPTION_LANGUAGE: BuildFormValidator
8 readonly VIDEO_CAPTION_FILE: BuildFormValidator
9
10 constructor () {
11
12 this.VIDEO_CAPTION_LANGUAGE = {
13 VALIDATORS: [ Validators.required ],
14 MESSAGES: {
15 'required': $localize`Video caption language is required.`
16 }
17 }
18
19 this.VIDEO_CAPTION_FILE = {
20 VALIDATORS: [ Validators.required ],
21 MESSAGES: {
22 'required': $localize`Video caption file is required.`
23 }
24 }
25 }
26}
diff --git a/client/src/app/shared/shared-forms/form-validators/video-change-ownership-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-change-ownership-validators.service.ts
deleted file mode 100644
index 8c809a0d5..000000000
--- a/client/src/app/shared/shared-forms/form-validators/video-change-ownership-validators.service.ts
+++ /dev/null
@@ -1,26 +0,0 @@
1import { Injectable } from '@angular/core'
2import { AbstractControl, ValidationErrors, Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service'
4
5@Injectable()
6export class VideoChangeOwnershipValidatorsService {
7 readonly USERNAME: BuildFormValidator
8
9 constructor () {
10 this.USERNAME = {
11 VALIDATORS: [ Validators.required, this.localAccountValidator ],
12 MESSAGES: {
13 'required': $localize`The username is required.`,
14 'localAccountOnly': $localize`You can only transfer ownership to a local account`
15 }
16 }
17 }
18
19 localAccountValidator (control: AbstractControl): ValidationErrors {
20 if (control.value.includes('@')) {
21 return { 'localAccountOnly': true }
22 }
23
24 return null
25 }
26}
diff --git a/client/src/app/shared/shared-forms/form-validators/video-channel-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-channel-validators.service.ts
deleted file mode 100644
index 3e7444196..000000000
--- a/client/src/app/shared/shared-forms/form-validators/video-channel-validators.service.ts
+++ /dev/null
@@ -1,63 +0,0 @@
1import { Injectable } from '@angular/core'
2import { Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service'
4
5@Injectable()
6export class VideoChannelValidatorsService {
7 readonly VIDEO_CHANNEL_NAME: BuildFormValidator
8 readonly VIDEO_CHANNEL_DISPLAY_NAME: BuildFormValidator
9 readonly VIDEO_CHANNEL_DESCRIPTION: BuildFormValidator
10 readonly VIDEO_CHANNEL_SUPPORT: BuildFormValidator
11
12 constructor () {
13 this.VIDEO_CHANNEL_NAME = {
14 VALIDATORS: [
15 Validators.required,
16 Validators.minLength(1),
17 Validators.maxLength(50),
18 Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
19 ],
20 MESSAGES: {
21 'required': $localize`Name is required.`,
22 'minlength': $localize`Name must be at least 1 character long.`,
23 'maxlength': $localize`Name cannot be more than 50 characters long.`,
24 'pattern': $localize`Name should be lowercase alphanumeric; dots and underscores are allowed.`
25 }
26 }
27
28 this.VIDEO_CHANNEL_DISPLAY_NAME = {
29 VALIDATORS: [
30 Validators.required,
31 Validators.minLength(1),
32 Validators.maxLength(50)
33 ],
34 MESSAGES: {
35 'required': $localize`Display name is required.`,
36 'minlength': $localize`Display name must be at least 1 character long.`,
37 'maxlength': $localize`Display name cannot be more than 50 characters long.`
38 }
39 }
40
41 this.VIDEO_CHANNEL_DESCRIPTION = {
42 VALIDATORS: [
43 Validators.minLength(3),
44 Validators.maxLength(1000)
45 ],
46 MESSAGES: {
47 'minlength': $localize`Description must be at least 3 characters long.`,
48 'maxlength': $localize`Description cannot be more than 1000 characters long.`
49 }
50 }
51
52 this.VIDEO_CHANNEL_SUPPORT = {
53 VALIDATORS: [
54 Validators.minLength(3),
55 Validators.maxLength(1000)
56 ],
57 MESSAGES: {
58 'minlength': $localize`Support text must be at least 3 characters long.`,
59 'maxlength': $localize`Support text cannot be more than 1000 characters long`
60 }
61 }
62 }
63}
diff --git a/client/src/app/shared/shared-forms/form-validators/video-comment-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-comment-validators.service.ts
deleted file mode 100644
index 18e7ae264..000000000
--- a/client/src/app/shared/shared-forms/form-validators/video-comment-validators.service.ts
+++ /dev/null
@@ -1,19 +0,0 @@
1import { Injectable } from '@angular/core'
2import { Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service'
4
5@Injectable()
6export class VideoCommentValidatorsService {
7 readonly VIDEO_COMMENT_TEXT: BuildFormValidator
8
9 constructor () {
10 this.VIDEO_COMMENT_TEXT = {
11 VALIDATORS: [ Validators.required, Validators.minLength(1), Validators.maxLength(3000) ],
12 MESSAGES: {
13 'required': $localize`Comment is required.`,
14 'minlength': $localize`Comment must be at least 2 characters long.`,
15 'maxlength': $localize`Comment cannot be more than 3000 characters long.`
16 }
17 }
18 }
19}
diff --git a/client/src/app/shared/shared-forms/form-validators/video-playlist-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-playlist-validators.service.ts
deleted file mode 100644
index 3b45a40fd..000000000
--- a/client/src/app/shared/shared-forms/form-validators/video-playlist-validators.service.ts
+++ /dev/null
@@ -1,65 +0,0 @@
1import { Injectable } from '@angular/core'
2import { AbstractControl, Validators } from '@angular/forms'
3import { VideoPlaylistPrivacy } from '@shared/models'
4import { BuildFormValidator } from './form-validator.service'
5
6@Injectable()
7export class VideoPlaylistValidatorsService {
8 readonly VIDEO_PLAYLIST_DISPLAY_NAME: BuildFormValidator
9 readonly VIDEO_PLAYLIST_PRIVACY: BuildFormValidator
10 readonly VIDEO_PLAYLIST_DESCRIPTION: BuildFormValidator
11 readonly VIDEO_PLAYLIST_CHANNEL_ID: BuildFormValidator
12
13 constructor () {
14 this.VIDEO_PLAYLIST_DISPLAY_NAME = {
15 VALIDATORS: [
16 Validators.required,
17 Validators.minLength(1),
18 Validators.maxLength(120)
19 ],
20 MESSAGES: {
21 'required': $localize`Display name is required.`,
22 'minlength': $localize`Display name must be at least 1 character long.`,
23 'maxlength': $localize`Display name cannot be more than 120 characters long.`
24 }
25 }
26
27 this.VIDEO_PLAYLIST_PRIVACY = {
28 VALIDATORS: [
29 Validators.required
30 ],
31 MESSAGES: {
32 'required': $localize`Privacy is required.`
33 }
34 }
35
36 this.VIDEO_PLAYLIST_DESCRIPTION = {
37 VALIDATORS: [
38 Validators.minLength(3),
39 Validators.maxLength(1000)
40 ],
41 MESSAGES: {
42 'minlength': $localize`Description must be at least 3 characters long.`,
43 'maxlength': $localize`Description cannot be more than 1000 characters long.`
44 }
45 }
46
47 this.VIDEO_PLAYLIST_CHANNEL_ID = {
48 VALIDATORS: [ ],
49 MESSAGES: {
50 'required': $localize`The channel is required when the playlist is public.`
51 }
52 }
53 }
54
55 setChannelValidator (channelControl: AbstractControl, privacy: VideoPlaylistPrivacy) {
56 if (privacy.toString() === VideoPlaylistPrivacy.PUBLIC.toString()) {
57 channelControl.setValidators([ Validators.required ])
58 } else {
59 channelControl.setValidators(null)
60 }
61
62 channelControl.markAsDirty()
63 channelControl.updateValueAndValidity()
64 }
65}
diff --git a/client/src/app/shared/shared-forms/form-validators/video-validators.service.ts b/client/src/app/shared/shared-forms/form-validators/video-validators.service.ts
deleted file mode 100644
index 8119c1ae7..000000000
--- a/client/src/app/shared/shared-forms/form-validators/video-validators.service.ts
+++ /dev/null
@@ -1,122 +0,0 @@
1import { Injectable } from '@angular/core'
2import { AbstractControl, ValidationErrors, ValidatorFn, Validators } from '@angular/forms'
3import { BuildFormValidator } from './form-validator.service'
4
5@Injectable()
6export class VideoValidatorsService {
7 readonly VIDEO_NAME: BuildFormValidator
8 readonly VIDEO_PRIVACY: BuildFormValidator
9 readonly VIDEO_CATEGORY: BuildFormValidator
10 readonly VIDEO_LICENCE: BuildFormValidator
11 readonly VIDEO_LANGUAGE: BuildFormValidator
12 readonly VIDEO_IMAGE: BuildFormValidator
13 readonly VIDEO_CHANNEL: BuildFormValidator
14 readonly VIDEO_DESCRIPTION: BuildFormValidator
15 readonly VIDEO_TAGS_ARRAY: BuildFormValidator
16 readonly VIDEO_TAG: BuildFormValidator
17 readonly VIDEO_SUPPORT: BuildFormValidator
18 readonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator
19 readonly VIDEO_ORIGINALLY_PUBLISHED_AT: BuildFormValidator
20
21 constructor () {
22
23 this.VIDEO_NAME = {
24 VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ],
25 MESSAGES: {
26 'required': $localize`Video name is required.`,
27 'minlength': $localize`Video name must be at least 3 characters long.`,
28 'maxlength': $localize`Video name cannot be more than 120 characters long.`
29 }
30 }
31
32 this.VIDEO_PRIVACY = {
33 VALIDATORS: [ Validators.required ],
34 MESSAGES: {
35 'required': $localize`Video privacy is required.`
36 }
37 }
38
39 this.VIDEO_CATEGORY = {
40 VALIDATORS: [ ],
41 MESSAGES: {}
42 }
43
44 this.VIDEO_LICENCE = {
45 VALIDATORS: [ ],
46 MESSAGES: {}
47 }
48
49 this.VIDEO_LANGUAGE = {
50 VALIDATORS: [ ],
51 MESSAGES: {}
52 }
53
54 this.VIDEO_IMAGE = {
55 VALIDATORS: [ ],
56 MESSAGES: {}
57 }
58
59 this.VIDEO_CHANNEL = {
60 VALIDATORS: [ Validators.required ],
61 MESSAGES: {
62 'required': $localize`Video channel is required.`
63 }
64 }
65
66 this.VIDEO_DESCRIPTION = {
67 VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ],
68 MESSAGES: {
69 'minlength': $localize`Video description must be at least 3 characters long.`,
70 'maxlength': $localize`Video description cannot be more than 10000 characters long.`
71 }
72 }
73
74 this.VIDEO_TAG = {
75 VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ],
76 MESSAGES: {
77 'minlength': $localize`A tag should be more than 2 characters long.`,
78 'maxlength': $localize`A tag should be less than 30 characters long.`
79 }
80 }
81
82 this.VIDEO_TAGS_ARRAY = {
83 VALIDATORS: [ Validators.maxLength(5), this.arrayTagLengthValidator() ],
84 MESSAGES: {
85 'maxlength': $localize`A maximum of 5 tags can be used on a video.`,
86 'arrayTagLength': $localize`A tag should be more than 2, and less than 30 characters long.`
87 }
88 }
89
90 this.VIDEO_SUPPORT = {
91 VALIDATORS: [ Validators.minLength(3), Validators.maxLength(1000) ],
92 MESSAGES: {
93 'minlength': $localize`Video support must be at least 3 characters long.`,
94 'maxlength': $localize`Video support cannot be more than 1000 characters long.`
95 }
96 }
97
98 this.VIDEO_SCHEDULE_PUBLICATION_AT = {
99 VALIDATORS: [ ],
100 MESSAGES: {
101 'required': $localize`A date is required to schedule video update.`
102 }
103 }
104
105 this.VIDEO_ORIGINALLY_PUBLISHED_AT = {
106 VALIDATORS: [ ],
107 MESSAGES: {}
108 }
109 }
110
111 arrayTagLengthValidator (min = 2, max = 30): ValidatorFn {
112 return (control: AbstractControl): ValidationErrors => {
113 const array = control.value as Array<string>
114
115 if (array.every(e => e.length > min && e.length < max)) {
116 return null
117 }
118
119 return { 'arrayTagLength': true }
120 }
121 }
122}
diff --git a/client/src/app/shared/shared-forms/index.ts b/client/src/app/shared/shared-forms/index.ts
index 747df65cf..b2c7fa9ba 100644
--- a/client/src/app/shared/shared-forms/index.ts
+++ b/client/src/app/shared/shared-forms/index.ts
@@ -1,4 +1,4 @@
1export * from './form-validators' 1export * from './form-validator.service'
2export * from './form-reactive' 2export * from './form-reactive'
3export * from './select' 3export * from './select'
4export * from './input-readonly-copy.component' 4export * from './input-readonly-copy.component'
diff --git a/client/src/app/shared/shared-forms/shared-form.module.ts b/client/src/app/shared/shared-forms/shared-form.module.ts
index 0e0ed5bab..1946ac21f 100644
--- a/client/src/app/shared/shared-forms/shared-form.module.ts
+++ b/client/src/app/shared/shared-forms/shared-form.module.ts
@@ -1,37 +1,20 @@
1 1
2import { NgModule } from '@angular/core'
3import { FormsModule, ReactiveFormsModule } from '@angular/forms'
4import { InputMaskModule } from 'primeng/inputmask' 2import { InputMaskModule } from 'primeng/inputmask'
5import { InputSwitchModule } from 'primeng/inputswitch' 3import { InputSwitchModule } from 'primeng/inputswitch'
4import { NgModule } from '@angular/core'
5import { FormsModule, ReactiveFormsModule } from '@angular/forms'
6import { NgSelectModule } from '@ng-select/ng-select' 6import { NgSelectModule } from '@ng-select/ng-select'
7import { BatchDomainsValidatorsService } from '@app/shared/shared-forms/form-validators/batch-domains-validators.service'
8import { SharedGlobalIconModule } from '../shared-icons' 7import { SharedGlobalIconModule } from '../shared-icons'
9import { SharedMainModule } from '../shared-main/shared-main.module' 8import { SharedMainModule } from '../shared-main/shared-main.module'
10import { 9import { FormValidatorService } from './form-validator.service'
11 CustomConfigValidatorsService,
12 FormValidatorService,
13 InstanceValidatorsService,
14 LoginValidatorsService,
15 ResetPasswordValidatorsService,
16 UserValidatorsService,
17 AbuseValidatorsService,
18 VideoAcceptOwnershipValidatorsService,
19 VideoBlockValidatorsService,
20 VideoCaptionsValidatorsService,
21 VideoChangeOwnershipValidatorsService,
22 VideoChannelValidatorsService,
23 VideoCommentValidatorsService,
24 VideoPlaylistValidatorsService,
25 VideoValidatorsService
26} from './form-validators'
27import { InputReadonlyCopyComponent } from './input-readonly-copy.component' 10import { InputReadonlyCopyComponent } from './input-readonly-copy.component'
28import { MarkdownTextareaComponent } from './markdown-textarea.component' 11import { MarkdownTextareaComponent } from './markdown-textarea.component'
29import { PeertubeCheckboxComponent } from './peertube-checkbox.component' 12import { PeertubeCheckboxComponent } from './peertube-checkbox.component'
30import { PreviewUploadComponent } from './preview-upload.component' 13import { PreviewUploadComponent } from './preview-upload.component'
31import { ReactiveFileComponent } from './reactive-file.component' 14import { ReactiveFileComponent } from './reactive-file.component'
15import { SelectChannelComponent, SelectCheckboxComponent, SelectOptionsComponent, SelectTagsComponent } from './select'
32import { TextareaAutoResizeDirective } from './textarea-autoresize.directive' 16import { TextareaAutoResizeDirective } from './textarea-autoresize.directive'
33import { TimestampInputComponent } from './timestamp-input.component' 17import { TimestampInputComponent } from './timestamp-input.component'
34import { SelectChannelComponent, SelectCheckboxComponent, SelectOptionsComponent, SelectTagsComponent } from './select'
35 18
36@NgModule({ 19@NgModule({
37 imports: [ 20 imports: [
@@ -84,23 +67,7 @@ import { SelectChannelComponent, SelectCheckboxComponent, SelectOptionsComponent
84 ], 67 ],
85 68
86 providers: [ 69 providers: [
87 CustomConfigValidatorsService, 70 FormValidatorService
88 FormValidatorService,
89 LoginValidatorsService,
90 InstanceValidatorsService,
91 LoginValidatorsService,
92 ResetPasswordValidatorsService,
93 UserValidatorsService,
94 AbuseValidatorsService,
95 VideoAcceptOwnershipValidatorsService,
96 VideoBlockValidatorsService,
97 VideoCaptionsValidatorsService,
98 VideoChangeOwnershipValidatorsService,
99 VideoChannelValidatorsService,
100 VideoCommentValidatorsService,
101 VideoPlaylistValidatorsService,
102 VideoValidatorsService,
103 BatchDomainsValidatorsService
104 ] 71 ]
105}) 72})
106export class SharedFormModule { } 73export class SharedFormModule { }
diff --git a/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts b/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts
index 7193ccb1b..6edbb6023 100644
--- a/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts
+++ b/client/src/app/shared/shared-moderation/batch-domains-modal.component.ts
@@ -1,7 +1,8 @@
1import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' 1import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
2import { BatchDomainsValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms' 2import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
3import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 3import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
4import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 4import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
5import { DOMAINS_VALIDATOR, getNotEmptyHosts } from '../form-validators/batch-domains-validators'
5 6
6@Component({ 7@Component({
7 selector: 'my-batch-domains-modal', 8 selector: 'my-batch-domains-modal',
@@ -18,8 +19,7 @@ export class BatchDomainsModalComponent extends FormReactive implements OnInit {
18 19
19 constructor ( 20 constructor (
20 protected formValidatorService: FormValidatorService, 21 protected formValidatorService: FormValidatorService,
21 private modalService: NgbModal, 22 private modalService: NgbModal
22 private batchDomainsValidatorsService: BatchDomainsValidatorsService
23 ) { 23 ) {
24 super() 24 super()
25 } 25 }
@@ -28,7 +28,7 @@ export class BatchDomainsModalComponent extends FormReactive implements OnInit {
28 if (!this.action) this.action = $localize`Process domains` 28 if (!this.action) this.action = $localize`Process domains`
29 29
30 this.buildForm({ 30 this.buildForm({
31 domains: this.batchDomainsValidatorsService.DOMAINS 31 domains: DOMAINS_VALIDATOR
32 }) 32 })
33 } 33 }
34 34
@@ -42,7 +42,7 @@ export class BatchDomainsModalComponent extends FormReactive implements OnInit {
42 42
43 submit () { 43 submit () {
44 this.domains.emit( 44 this.domains.emit(
45 this.batchDomainsValidatorsService.getNotEmptyHosts(this.form.controls['domains'].value) 45 getNotEmptyHosts(this.form.controls['domains'].value)
46 ) 46 )
47 this.form.reset() 47 this.form.reset()
48 this.hide() 48 this.hide()
diff --git a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts
index 8ab2fe940..cc8875f77 100644
--- a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts
+++ b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts
@@ -1,7 +1,8 @@
1import { mapValues, pickBy } from 'lodash-es' 1import { mapValues, pickBy } from 'lodash-es'
2import { Component, Input, OnInit, ViewChild } from '@angular/core' 2import { Component, Input, OnInit, ViewChild } from '@angular/core'
3import { Notifier } from '@app/core' 3import { Notifier } from '@app/core'
4import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms' 4import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators'
5import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
5import { Account } from '@app/shared/shared-main' 6import { Account } from '@app/shared/shared-main'
6import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 7import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
7import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 8import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
@@ -28,7 +29,6 @@ export class AccountReportComponent extends FormReactive implements OnInit {
28 constructor ( 29 constructor (
29 protected formValidatorService: FormValidatorService, 30 protected formValidatorService: FormValidatorService,
30 private modalService: NgbModal, 31 private modalService: NgbModal,
31 private abuseValidatorsService: AbuseValidatorsService,
32 private abuseService: AbuseService, 32 private abuseService: AbuseService,
33 private notifier: Notifier 33 private notifier: Notifier
34 ) { 34 ) {
@@ -51,7 +51,7 @@ export class AccountReportComponent extends FormReactive implements OnInit {
51 this.modalTitle = $localize`Report ${this.account.displayName}` 51 this.modalTitle = $localize`Report ${this.account.displayName}`
52 52
53 this.buildForm({ 53 this.buildForm({
54 reason: this.abuseValidatorsService.ABUSE_REASON, 54 reason: ABUSE_REASON_VALIDATOR,
55 predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null) 55 predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null)
56 }) 56 })
57 57
diff --git a/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts
index d75f4d717..c7395c7b7 100644
--- a/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts
+++ b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts
@@ -1,7 +1,8 @@
1import { mapValues, pickBy } from 'lodash-es' 1import { mapValues, pickBy } from 'lodash-es'
2import { Component, Input, OnInit, ViewChild } from '@angular/core' 2import { Component, Input, OnInit, ViewChild } from '@angular/core'
3import { Notifier } from '@app/core' 3import { Notifier } from '@app/core'
4import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms' 4import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators'
5import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
5import { VideoComment } from '@app/shared/shared-video-comment' 6import { VideoComment } from '@app/shared/shared-video-comment'
6import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 7import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
7import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 8import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
@@ -28,7 +29,6 @@ export class CommentReportComponent extends FormReactive implements OnInit {
28 constructor ( 29 constructor (
29 protected formValidatorService: FormValidatorService, 30 protected formValidatorService: FormValidatorService,
30 private modalService: NgbModal, 31 private modalService: NgbModal,
31 private abuseValidatorsService: AbuseValidatorsService,
32 private abuseService: AbuseService, 32 private abuseService: AbuseService,
33 private notifier: Notifier 33 private notifier: Notifier
34 ) { 34 ) {
@@ -51,7 +51,7 @@ export class CommentReportComponent extends FormReactive implements OnInit {
51 this.modalTitle = $localize`Report comment` 51 this.modalTitle = $localize`Report comment`
52 52
53 this.buildForm({ 53 this.buildForm({
54 reason: this.abuseValidatorsService.ABUSE_REASON, 54 reason: ABUSE_REASON_VALIDATOR,
55 predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null) 55 predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null)
56 }) 56 })
57 57
diff --git a/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts
index edff6d325..5b06c0bc7 100644
--- a/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts
+++ b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts
@@ -3,7 +3,8 @@ import { buildVideoLink, buildVideoOrPlaylistEmbed } from 'src/assets/player/uti
3import { Component, Input, OnInit, ViewChild } from '@angular/core' 3import { Component, Input, OnInit, ViewChild } from '@angular/core'
4import { DomSanitizer, SafeHtml } from '@angular/platform-browser' 4import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
5import { Notifier } from '@app/core' 5import { Notifier } from '@app/core'
6import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms' 6import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators'
7import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
7import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 8import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
8import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 9import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
9import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' 10import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
@@ -30,7 +31,6 @@ export class VideoReportComponent extends FormReactive implements OnInit {
30 constructor ( 31 constructor (
31 protected formValidatorService: FormValidatorService, 32 protected formValidatorService: FormValidatorService,
32 private modalService: NgbModal, 33 private modalService: NgbModal,
33 private abuseValidatorsService: AbuseValidatorsService,
34 private abuseService: AbuseService, 34 private abuseService: AbuseService,
35 private notifier: Notifier, 35 private notifier: Notifier,
36 private sanitizer: DomSanitizer 36 private sanitizer: DomSanitizer
@@ -68,7 +68,7 @@ export class VideoReportComponent extends FormReactive implements OnInit {
68 68
69 ngOnInit () { 69 ngOnInit () {
70 this.buildForm({ 70 this.buildForm({
71 reason: this.abuseValidatorsService.ABUSE_REASON, 71 reason: ABUSE_REASON_VALIDATOR,
72 predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null), 72 predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null),
73 timestamp: { 73 timestamp: {
74 hasStart: null, 74 hasStart: null,
diff --git a/client/src/app/shared/shared-moderation/user-ban-modal.component.ts b/client/src/app/shared/shared-moderation/user-ban-modal.component.ts
index f9a0381c5..afc69a1b8 100644
--- a/client/src/app/shared/shared-moderation/user-ban-modal.component.ts
+++ b/client/src/app/shared/shared-moderation/user-ban-modal.component.ts
@@ -1,9 +1,10 @@
1import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' 1import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
2import { Notifier, UserService } from '@app/core' 2import { Notifier, UserService } from '@app/core'
3import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' 3import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
4import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 4import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
5import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 5import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
6import { User } from '@shared/models' 6import { User } from '@shared/models'
7import { USER_BAN_REASON_VALIDATOR } from '../form-validators/user-validators'
7 8
8@Component({ 9@Component({
9 selector: 'my-user-ban-modal', 10 selector: 'my-user-ban-modal',
@@ -21,15 +22,14 @@ export class UserBanModalComponent extends FormReactive implements OnInit {
21 protected formValidatorService: FormValidatorService, 22 protected formValidatorService: FormValidatorService,
22 private modalService: NgbModal, 23 private modalService: NgbModal,
23 private notifier: Notifier, 24 private notifier: Notifier,
24 private userService: UserService, 25 private userService: UserService
25 private userValidatorsService: UserValidatorsService
26 ) { 26 ) {
27 super() 27 super()
28 } 28 }
29 29
30 ngOnInit () { 30 ngOnInit () {
31 this.buildForm({ 31 this.buildForm({
32 reason: this.userValidatorsService.USER_BAN_REASON 32 reason: USER_BAN_REASON_VALIDATOR
33 }) 33 })
34 } 34 }
35 35
diff --git a/client/src/app/shared/shared-moderation/video-block.component.ts b/client/src/app/shared/shared-moderation/video-block.component.ts
index 2bef9efdd..fb47989dc 100644
--- a/client/src/app/shared/shared-moderation/video-block.component.ts
+++ b/client/src/app/shared/shared-moderation/video-block.component.ts
@@ -1,9 +1,10 @@
1import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' 1import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
2import { Notifier } from '@app/core' 2import { Notifier } from '@app/core'
3import { FormReactive, FormValidatorService, VideoBlockValidatorsService } from '@app/shared/shared-forms' 3import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
4import { Video } from '@app/shared/shared-main' 4import { Video } from '@app/shared/shared-main'
5import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 5import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
6import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 6import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
7import { VIDEO_BLOCK_REASON_VALIDATOR } from '../form-validators/video-block-validators'
7import { VideoBlockService } from './video-block.service' 8import { VideoBlockService } from './video-block.service'
8 9
9@Component({ 10@Component({
@@ -25,7 +26,6 @@ export class VideoBlockComponent extends FormReactive implements OnInit {
25 constructor ( 26 constructor (
26 protected formValidatorService: FormValidatorService, 27 protected formValidatorService: FormValidatorService,
27 private modalService: NgbModal, 28 private modalService: NgbModal,
28 private videoBlockValidatorsService: VideoBlockValidatorsService,
29 private videoBlocklistService: VideoBlockService, 29 private videoBlocklistService: VideoBlockService,
30 private notifier: Notifier 30 private notifier: Notifier
31 ) { 31 ) {
@@ -36,7 +36,7 @@ export class VideoBlockComponent extends FormReactive implements OnInit {
36 const defaultValues = { unfederate: 'true' } 36 const defaultValues = { unfederate: 'true' }
37 37
38 this.buildForm({ 38 this.buildForm({
39 reason: this.videoBlockValidatorsService.VIDEO_BLOCK_REASON, 39 reason: VIDEO_BLOCK_REASON_VALIDATOR,
40 unfederate: null 40 unfederate: null
41 }, defaultValues) 41 }, defaultValues)
42 } 42 }
diff --git a/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts b/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts
index 286ecac02..b46c91bf8 100644
--- a/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts
+++ b/client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts
@@ -1,5 +1,6 @@
1import { Component, Input, OnInit } from '@angular/core' 1import { Component, Input, OnInit } from '@angular/core'
2import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' 2import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
3import { USER_EMAIL_VALIDATOR } from '../form-validators/user-validators'
3 4
4@Component({ 5@Component({
5 selector: 'my-remote-subscribe', 6 selector: 'my-remote-subscribe',
@@ -12,15 +13,14 @@ export class RemoteSubscribeComponent extends FormReactive implements OnInit {
12 @Input() showHelp = false 13 @Input() showHelp = false
13 14
14 constructor ( 15 constructor (
15 protected formValidatorService: FormValidatorService, 16 protected formValidatorService: FormValidatorService
16 private userValidatorsService: UserValidatorsService
17 ) { 17 ) {
18 super() 18 super()
19 } 19 }
20 20
21 ngOnInit () { 21 ngOnInit () {
22 this.buildForm({ 22 this.buildForm({
23 text: this.userValidatorsService.USER_EMAIL 23 text: USER_EMAIL_VALIDATOR
24 }) 24 })
25 } 25 }
26 26
diff --git a/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts b/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts
index 757ffa099..41f16e0bf 100644
--- a/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts
+++ b/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts
@@ -3,9 +3,10 @@ import { Subject, Subscription } from 'rxjs'
3import { debounceTime, filter } from 'rxjs/operators' 3import { debounceTime, filter } from 'rxjs/operators'
4import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core' 4import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'
5import { AuthService, DisableForReuseHook, Notifier } from '@app/core' 5import { AuthService, DisableForReuseHook, Notifier } from '@app/core'
6import { FormReactive, FormValidatorService, VideoPlaylistValidatorsService } from '@app/shared/shared-forms' 6import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
7import { Video, VideoExistInPlaylist, VideoPlaylistCreate, VideoPlaylistElementCreate, VideoPlaylistPrivacy } from '@shared/models' 7import { Video, VideoExistInPlaylist, VideoPlaylistCreate, VideoPlaylistElementCreate, VideoPlaylistPrivacy } from '@shared/models'
8import { secondsToTime } from '../../../assets/player/utils' 8import { secondsToTime } from '../../../assets/player/utils'
9import { VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR } from '../form-validators/video-playlist-validators'
9import { CachedPlaylist, VideoPlaylistService } from './video-playlist.service' 10import { CachedPlaylist, VideoPlaylistService } from './video-playlist.service'
10 11
11const logger = debug('peertube:playlists:VideoAddToPlaylistComponent') 12const logger = debug('peertube:playlists:VideoAddToPlaylistComponent')
@@ -53,7 +54,6 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
53 private authService: AuthService, 54 private authService: AuthService,
54 private notifier: Notifier, 55 private notifier: Notifier,
55 private videoPlaylistService: VideoPlaylistService, 56 private videoPlaylistService: VideoPlaylistService,
56 private videoPlaylistValidatorsService: VideoPlaylistValidatorsService,
57 private cd: ChangeDetectorRef 57 private cd: ChangeDetectorRef
58 ) { 58 ) {
59 super() 59 super()
@@ -65,7 +65,7 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
65 65
66 ngOnInit () { 66 ngOnInit () {
67 this.buildForm({ 67 this.buildForm({
68 displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME 68 displayName: VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR
69 }) 69 })
70 70
71 this.videoPlaylistService.listenToMyAccountPlaylistsChange() 71 this.videoPlaylistService.listenToMyAccountPlaylistsChange()