aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/+about/about-instance/contact-admin-modal.component.ts17
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts45
-rw-r--r--client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts3
-rw-r--r--client/src/app/+admin/users/user-edit/user-create.component.ts27
-rw-r--r--client/src/app/+admin/users/user-edit/user-password.component.ts6
-rw-r--r--client/src/app/+admin/users/user-edit/user-update.component.ts17
-rw-r--r--client/src/app/+login/login.component.ts8
-rw-r--r--client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts17
-rw-r--r--client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-update.component.ts14
-rw-r--r--client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.ts6
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts10
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts10
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts10
-rw-r--r--client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts20
-rw-r--r--client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts20
-rw-r--r--client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts6
-rw-r--r--client/src/app/+reset-password/reset-password.component.ts10
-rw-r--r--client/src/app/+signup/+register/register-step-channel.component.ts10
-rw-r--r--client/src/app/+signup/+register/register-step-user.component.ts22
-rw-r--r--client/src/app/+signup/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.ts6
-rw-r--r--client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts10
-rw-r--r--client/src/app/+videos/+video-edit/shared/video-edit.component.ts38
-rw-r--r--client/src/app/+videos/+video-watch/comment/video-comment-add.component.ts6
-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
70 files changed, 940 insertions, 1077 deletions
diff --git a/client/src/app/+about/about-instance/contact-admin-modal.component.ts b/client/src/app/+about/about-instance/contact-admin-modal.component.ts
index 215e281bb..11e442f6b 100644
--- a/client/src/app/+about/about-instance/contact-admin-modal.component.ts
+++ b/client/src/app/+about/about-instance/contact-admin-modal.component.ts
@@ -1,6 +1,12 @@
1import { Component, OnInit, ViewChild } from '@angular/core' 1import { Component, OnInit, ViewChild } from '@angular/core'
2import { Notifier, ServerService } from '@app/core' 2import { Notifier, ServerService } from '@app/core'
3import { FormReactive, FormValidatorService, InstanceValidatorsService } from '@app/shared/shared-forms' 3import {
4 BODY_VALIDATOR,
5 FROM_EMAIL_VALIDATOR,
6 FROM_NAME_VALIDATOR,
7 SUBJECT_VALIDATOR
8} from '@app/shared/form-validators/instance-validators'
9import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
4import { InstanceService } from '@app/shared/shared-instance' 10import { InstanceService } from '@app/shared/shared-instance'
5import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 11import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
6import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 12import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
@@ -22,7 +28,6 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit {
22 constructor ( 28 constructor (
23 protected formValidatorService: FormValidatorService, 29 protected formValidatorService: FormValidatorService,
24 private modalService: NgbModal, 30 private modalService: NgbModal,
25 private instanceValidatorsService: InstanceValidatorsService,
26 private instanceService: InstanceService, 31 private instanceService: InstanceService,
27 private serverService: ServerService, 32 private serverService: ServerService,
28 private notifier: Notifier 33 private notifier: Notifier
@@ -40,10 +45,10 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit {
40 .subscribe(config => this.serverConfig = config) 45 .subscribe(config => this.serverConfig = config)
41 46
42 this.buildForm({ 47 this.buildForm({
43 fromName: this.instanceValidatorsService.FROM_NAME, 48 fromName: FROM_NAME_VALIDATOR,
44 fromEmail: this.instanceValidatorsService.FROM_EMAIL, 49 fromEmail: FROM_EMAIL_VALIDATOR,
45 subject: this.instanceValidatorsService.SUBJECT, 50 subject: SUBJECT_VALIDATOR,
46 body: this.instanceValidatorsService.BODY 51 body: BODY_VALIDATOR
47 }) 52 })
48 } 53 }
49 54
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
index 3a60b144f..78e9dd5e5 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
+++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
@@ -5,12 +5,19 @@ import { ConfigService } from '@app/+admin/config/shared/config.service'
5import { Notifier } from '@app/core' 5import { Notifier } from '@app/core'
6import { ServerService } from '@app/core/server/server.service' 6import { ServerService } from '@app/core/server/server.service'
7import { 7import {
8 CustomConfigValidatorsService, 8 ADMIN_EMAIL_VALIDATOR,
9 FormReactive, 9 CACHE_CAPTIONS_SIZE_VALIDATOR,
10 FormValidatorService, 10 CACHE_PREVIEWS_SIZE_VALIDATOR,
11 SelectOptionsItem, 11 INDEX_URL_VALIDATOR,
12 UserValidatorsService 12 INSTANCE_NAME_VALIDATOR,
13} from '@app/shared/shared-forms' 13 INSTANCE_SHORT_DESCRIPTION_VALIDATOR,
14 SEARCH_INDEX_URL_VALIDATOR,
15 SERVICES_TWITTER_USERNAME_VALIDATOR,
16 SIGNUP_LIMIT_VALIDATOR,
17 TRANSCODING_THREADS_VALIDATOR
18} from '@app/shared/form-validators/custom-config-validators'
19import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators'
20import { FormReactive, FormValidatorService, SelectOptionsItem } from '@app/shared/shared-forms'
14import { NgbNav } from '@ng-bootstrap/ng-bootstrap' 21import { NgbNav } from '@ng-bootstrap/ng-bootstrap'
15import { CustomConfig, ServerConfig } from '@shared/models' 22import { CustomConfig, ServerConfig } from '@shared/models'
16 23
@@ -37,8 +44,6 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
37 constructor ( 44 constructor (
38 private viewportScroller: ViewportScroller, 45 private viewportScroller: ViewportScroller,
39 protected formValidatorService: FormValidatorService, 46 protected formValidatorService: FormValidatorService,
40 private customConfigValidatorsService: CustomConfigValidatorsService,
41 private userValidatorsService: UserValidatorsService,
42 private notifier: Notifier, 47 private notifier: Notifier,
43 private configService: ConfigService, 48 private configService: ConfigService,
44 private serverService: ServerService 49 private serverService: ServerService
@@ -110,8 +115,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
110 115
111 const formGroupData: { [key in keyof CustomConfig ]: any } = { 116 const formGroupData: { [key in keyof CustomConfig ]: any } = {
112 instance: { 117 instance: {
113 name: this.customConfigValidatorsService.INSTANCE_NAME, 118 name: INSTANCE_NAME_VALIDATOR,
114 shortDescription: this.customConfigValidatorsService.INSTANCE_SHORT_DESCRIPTION, 119 shortDescription: INSTANCE_SHORT_DESCRIPTION_VALIDATOR,
115 description: null, 120 description: null,
116 121
117 isNSFW: false, 122 isNSFW: false,
@@ -143,21 +148,21 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
143 }, 148 },
144 services: { 149 services: {
145 twitter: { 150 twitter: {
146 username: this.customConfigValidatorsService.SERVICES_TWITTER_USERNAME, 151 username: SERVICES_TWITTER_USERNAME_VALIDATOR,
147 whitelisted: null 152 whitelisted: null
148 } 153 }
149 }, 154 },
150 cache: { 155 cache: {
151 previews: { 156 previews: {
152 size: this.customConfigValidatorsService.CACHE_PREVIEWS_SIZE 157 size: CACHE_PREVIEWS_SIZE_VALIDATOR
153 }, 158 },
154 captions: { 159 captions: {
155 size: this.customConfigValidatorsService.CACHE_CAPTIONS_SIZE 160 size: CACHE_CAPTIONS_SIZE_VALIDATOR
156 } 161 }
157 }, 162 },
158 signup: { 163 signup: {
159 enabled: null, 164 enabled: null,
160 limit: this.customConfigValidatorsService.SIGNUP_LIMIT, 165 limit: SIGNUP_LIMIT_VALIDATOR,
161 requiresEmailVerification: null 166 requiresEmailVerification: null
162 }, 167 },
163 import: { 168 import: {
@@ -171,18 +176,18 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
171 } 176 }
172 }, 177 },
173 admin: { 178 admin: {
174 email: this.customConfigValidatorsService.ADMIN_EMAIL 179 email: ADMIN_EMAIL_VALIDATOR
175 }, 180 },
176 contactForm: { 181 contactForm: {
177 enabled: null 182 enabled: null
178 }, 183 },
179 user: { 184 user: {
180 videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA, 185 videoQuota: USER_VIDEO_QUOTA_VALIDATOR,
181 videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY 186 videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR
182 }, 187 },
183 transcoding: { 188 transcoding: {
184 enabled: null, 189 enabled: null,
185 threads: this.customConfigValidatorsService.TRANSCODING_THREADS, 190 threads: TRANSCODING_THREADS_VALIDATOR,
186 allowAdditionalExtensions: null, 191 allowAdditionalExtensions: null,
187 allowAudioFiles: null, 192 allowAudioFiles: null,
188 resolutions: {}, 193 resolutions: {},
@@ -213,7 +218,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
213 }, 218 },
214 autoFollowIndex: { 219 autoFollowIndex: {
215 enabled: null, 220 enabled: null,
216 indexUrl: this.customConfigValidatorsService.INDEX_URL 221 indexUrl: INDEX_URL_VALIDATOR
217 } 222 }
218 } 223 }
219 }, 224 },
@@ -230,7 +235,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
230 }, 235 },
231 searchIndex: { 236 searchIndex: {
232 enabled: null, 237 enabled: null,
233 url: this.customConfigValidatorsService.SEARCH_INDEX_URL, 238 url: SEARCH_INDEX_URL_VALIDATOR,
234 disableLocalSearch: null, 239 disableLocalSearch: null,
235 isDefaultSearch: null 240 isDefaultSearch: null
236 } 241 }
diff --git a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts
index a33f01691..1acaf9674 100644
--- a/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts
+++ b/client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts
@@ -3,7 +3,8 @@ import { map, switchMap } from 'rxjs/operators'
3import { Component, OnDestroy, OnInit } from '@angular/core' 3import { Component, OnDestroy, OnInit } from '@angular/core'
4import { ActivatedRoute } from '@angular/router' 4import { ActivatedRoute } from '@angular/router'
5import { Notifier } from '@app/core' 5import { Notifier } from '@app/core'
6import { BuildFormArgument, FormReactive, FormValidatorService } from '@app/shared/shared-forms' 6import { BuildFormArgument } from '@app/shared/form-validators'
7import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
7import { PeerTubePlugin, RegisterServerSettingOptions } from '@shared/models' 8import { PeerTubePlugin, RegisterServerSettingOptions } from '@shared/models'
8import { PluginApiService } from '../shared/plugin-api.service' 9import { PluginApiService } from '../shared/plugin-api.service'
9 10
diff --git a/client/src/app/+admin/users/user-edit/user-create.component.ts b/client/src/app/+admin/users/user-edit/user-create.component.ts
index 36d71a927..d0aac1cb9 100644
--- a/client/src/app/+admin/users/user-edit/user-create.component.ts
+++ b/client/src/app/+admin/users/user-edit/user-create.component.ts
@@ -2,7 +2,17 @@ import { Component, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { ConfigService } from '@app/+admin/config/shared/config.service' 3import { ConfigService } from '@app/+admin/config/shared/config.service'
4import { AuthService, Notifier, ScreenService, ServerService, UserService } from '@app/core' 4import { AuthService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
5import { FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' 5import {
6 USER_CHANNEL_NAME_VALIDATOR,
7 USER_EMAIL_VALIDATOR,
8 USER_PASSWORD_OPTIONAL_VALIDATOR,
9 USER_PASSWORD_VALIDATOR,
10 USER_ROLE_VALIDATOR,
11 USER_USERNAME_VALIDATOR,
12 USER_VIDEO_QUOTA_DAILY_VALIDATOR,
13 USER_VIDEO_QUOTA_VALIDATOR
14} from '@app/shared/form-validators/user-validators'
15import { FormValidatorService } from '@app/shared/shared-forms'
6import { UserCreate, UserRole } from '@shared/models' 16import { UserCreate, UserRole } from '@shared/models'
7import { UserEdit } from './user-edit' 17import { UserEdit } from './user-edit'
8 18
@@ -20,7 +30,6 @@ export class UserCreateComponent extends UserEdit implements OnInit {
20 protected configService: ConfigService, 30 protected configService: ConfigService,
21 protected screenService: ScreenService, 31 protected screenService: ScreenService,
22 protected auth: AuthService, 32 protected auth: AuthService,
23 private userValidatorsService: UserValidatorsService,
24 private route: ActivatedRoute, 33 private route: ActivatedRoute,
25 private router: Router, 34 private router: Router,
26 private notifier: Notifier, 35 private notifier: Notifier,
@@ -41,13 +50,13 @@ export class UserCreateComponent extends UserEdit implements OnInit {
41 } 50 }
42 51
43 this.buildForm({ 52 this.buildForm({
44 username: this.userValidatorsService.USER_USERNAME, 53 username: USER_USERNAME_VALIDATOR,
45 channelName: this.userValidatorsService.USER_CHANNEL_NAME, 54 channelName: USER_CHANNEL_NAME_VALIDATOR,
46 email: this.userValidatorsService.USER_EMAIL, 55 email: USER_EMAIL_VALIDATOR,
47 password: this.isPasswordOptional() ? this.userValidatorsService.USER_PASSWORD_OPTIONAL : this.userValidatorsService.USER_PASSWORD, 56 password: this.isPasswordOptional() ? USER_PASSWORD_OPTIONAL_VALIDATOR : USER_PASSWORD_VALIDATOR,
48 role: this.userValidatorsService.USER_ROLE, 57 role: USER_ROLE_VALIDATOR,
49 videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA, 58 videoQuota: USER_VIDEO_QUOTA_VALIDATOR,
50 videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY, 59 videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR,
51 byPassAutoBlock: null 60 byPassAutoBlock: null
52 }, defaultValues) 61 }, defaultValues)
53 } 62 }
diff --git a/client/src/app/+admin/users/user-edit/user-password.component.ts b/client/src/app/+admin/users/user-edit/user-password.component.ts
index 25f13495a..05d52b17f 100644
--- a/client/src/app/+admin/users/user-edit/user-password.component.ts
+++ b/client/src/app/+admin/users/user-edit/user-password.component.ts
@@ -1,6 +1,7 @@
1import { Component, Input, OnInit } from '@angular/core' 1import { Component, Input, OnInit } 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 { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
4import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
4import { UserUpdate } from '@shared/models' 5import { UserUpdate } from '@shared/models'
5 6
6@Component({ 7@Component({
@@ -17,7 +18,6 @@ export class UserPasswordComponent extends FormReactive implements OnInit {
17 18
18 constructor ( 19 constructor (
19 protected formValidatorService: FormValidatorService, 20 protected formValidatorService: FormValidatorService,
20 private userValidatorsService: UserValidatorsService,
21 private notifier: Notifier, 21 private notifier: Notifier,
22 private userService: UserService 22 private userService: UserService
23 ) { 23 ) {
@@ -26,7 +26,7 @@ export class UserPasswordComponent extends FormReactive implements OnInit {
26 26
27 ngOnInit () { 27 ngOnInit () {
28 this.buildForm({ 28 this.buildForm({
29 password: this.userValidatorsService.USER_PASSWORD 29 password: USER_PASSWORD_VALIDATOR
30 }) 30 })
31 } 31 }
32 32
diff --git a/client/src/app/+admin/users/user-edit/user-update.component.ts b/client/src/app/+admin/users/user-edit/user-update.component.ts
index 55bc7290e..e16f66a2b 100644
--- a/client/src/app/+admin/users/user-edit/user-update.component.ts
+++ b/client/src/app/+admin/users/user-edit/user-update.component.ts
@@ -3,7 +3,13 @@ import { Component, OnDestroy, OnInit } from '@angular/core'
3import { ActivatedRoute, Router } from '@angular/router' 3import { ActivatedRoute, Router } from '@angular/router'
4import { ConfigService } from '@app/+admin/config/shared/config.service' 4import { ConfigService } from '@app/+admin/config/shared/config.service'
5import { AuthService, Notifier, ScreenService, ServerService, User, UserService } from '@app/core' 5import { AuthService, Notifier, ScreenService, ServerService, User, UserService } from '@app/core'
6import { FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' 6import {
7 USER_EMAIL_VALIDATOR,
8 USER_ROLE_VALIDATOR,
9 USER_VIDEO_QUOTA_DAILY_VALIDATOR,
10 USER_VIDEO_QUOTA_VALIDATOR
11} from '@app/shared/form-validators/user-validators'
12import { FormValidatorService } from '@app/shared/shared-forms'
7import { User as UserType, UserAdminFlag, UserRole, UserUpdate } from '@shared/models' 13import { User as UserType, UserAdminFlag, UserRole, UserUpdate } from '@shared/models'
8import { UserEdit } from './user-edit' 14import { UserEdit } from './user-edit'
9 15
@@ -23,7 +29,6 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
23 protected configService: ConfigService, 29 protected configService: ConfigService,
24 protected screenService: ScreenService, 30 protected screenService: ScreenService,
25 protected auth: AuthService, 31 protected auth: AuthService,
26 private userValidatorsService: UserValidatorsService,
27 private route: ActivatedRoute, 32 private route: ActivatedRoute,
28 private router: Router, 33 private router: Router,
29 private notifier: Notifier, 34 private notifier: Notifier,
@@ -44,10 +49,10 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
44 } 49 }
45 50
46 this.buildForm({ 51 this.buildForm({
47 email: this.userValidatorsService.USER_EMAIL, 52 email: USER_EMAIL_VALIDATOR,
48 role: this.userValidatorsService.USER_ROLE, 53 role: USER_ROLE_VALIDATOR,
49 videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA, 54 videoQuota: USER_VIDEO_QUOTA_VALIDATOR,
50 videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY, 55 videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR,
51 byPassAutoBlock: null 56 byPassAutoBlock: null
52 }, defaultValues) 57 }, defaultValues)
53 58
diff --git a/client/src/app/+login/login.component.ts b/client/src/app/+login/login.component.ts
index e9336172e..351750453 100644
--- a/client/src/app/+login/login.component.ts
+++ b/client/src/app/+login/login.component.ts
@@ -3,7 +3,8 @@ import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angula
3import { ActivatedRoute } from '@angular/router' 3import { ActivatedRoute } from '@angular/router'
4import { AuthService, Notifier, RedirectService, UserService } from '@app/core' 4import { AuthService, Notifier, RedirectService, UserService } from '@app/core'
5import { HooksService } from '@app/core/plugins/hooks.service' 5import { HooksService } from '@app/core/plugins/hooks.service'
6import { FormReactive, FormValidatorService, LoginValidatorsService } from '@app/shared/shared-forms' 6import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators'
7import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
7import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' 8import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
8import { RegisteredExternalAuthConfig, ServerConfig } from '@shared/models' 9import { RegisteredExternalAuthConfig, ServerConfig } from '@shared/models'
9 10
@@ -31,7 +32,6 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
31 protected formValidatorService: FormValidatorService, 32 protected formValidatorService: FormValidatorService,
32 private route: ActivatedRoute, 33 private route: ActivatedRoute,
33 private modalService: NgbModal, 34 private modalService: NgbModal,
34 private loginValidatorsService: LoginValidatorsService,
35 private authService: AuthService, 35 private authService: AuthService,
36 private userService: UserService, 36 private userService: UserService,
37 private redirectService: RedirectService, 37 private redirectService: RedirectService,
@@ -65,8 +65,8 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
65 } 65 }
66 66
67 this.buildForm({ 67 this.buildForm({
68 username: this.loginValidatorsService.LOGIN_USERNAME, 68 username: LOGIN_USERNAME_VALIDATOR,
69 password: this.loginValidatorsService.LOGIN_PASSWORD 69 password: LOGIN_PASSWORD_VALIDATOR
70 }) 70 })
71 } 71 }
72 72
diff --git a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts
index 5c438c3bf..e2ea87fb8 100644
--- a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts
+++ b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts
@@ -1,7 +1,13 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { Router } from '@angular/router' 2import { Router } from '@angular/router'
3import { AuthService, Notifier } from '@app/core' 3import { AuthService, Notifier } from '@app/core'
4import { FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms' 4import {
5 VIDEO_CHANNEL_DESCRIPTION_VALIDATOR,
6 VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
7 VIDEO_CHANNEL_NAME_VALIDATOR,
8 VIDEO_CHANNEL_SUPPORT_VALIDATOR
9} from '@app/shared/form-validators/video-channel-validators'
10import { FormValidatorService } from '@app/shared/shared-forms'
5import { VideoChannelService } from '@app/shared/shared-main' 11import { VideoChannelService } from '@app/shared/shared-main'
6import { VideoChannelCreate } from '@shared/models' 12import { VideoChannelCreate } from '@shared/models'
7import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' 13import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
@@ -17,7 +23,6 @@ export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelE
17 constructor ( 23 constructor (
18 protected formValidatorService: FormValidatorService, 24 protected formValidatorService: FormValidatorService,
19 private authService: AuthService, 25 private authService: AuthService,
20 private videoChannelValidatorsService: VideoChannelValidatorsService,
21 private notifier: Notifier, 26 private notifier: Notifier,
22 private router: Router, 27 private router: Router,
23 private videoChannelService: VideoChannelService 28 private videoChannelService: VideoChannelService
@@ -31,10 +36,10 @@ export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelE
31 36
32 ngOnInit () { 37 ngOnInit () {
33 this.buildForm({ 38 this.buildForm({
34 name: this.videoChannelValidatorsService.VIDEO_CHANNEL_NAME, 39 name: VIDEO_CHANNEL_NAME_VALIDATOR,
35 'display-name': this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME, 40 'display-name': VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
36 description: this.videoChannelValidatorsService.VIDEO_CHANNEL_DESCRIPTION, 41 description: VIDEO_CHANNEL_DESCRIPTION_VALIDATOR,
37 support: this.videoChannelValidatorsService.VIDEO_CHANNEL_SUPPORT 42 support: VIDEO_CHANNEL_SUPPORT_VALIDATOR
38 }) 43 })
39 } 44 }
40 45
diff --git a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-update.component.ts b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-update.component.ts
index 485521dcc..01659b8da 100644
--- a/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-update.component.ts
+++ b/client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-update.component.ts
@@ -2,7 +2,12 @@ import { Subscription } from 'rxjs'
2import { Component, OnDestroy, OnInit } from '@angular/core' 2import { Component, OnDestroy, OnInit } from '@angular/core'
3import { ActivatedRoute, Router } from '@angular/router' 3import { ActivatedRoute, Router } from '@angular/router'
4import { AuthService, Notifier, ServerService } from '@app/core' 4import { AuthService, Notifier, ServerService } from '@app/core'
5import { FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms' 5import {
6 VIDEO_CHANNEL_DESCRIPTION_VALIDATOR,
7 VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
8 VIDEO_CHANNEL_SUPPORT_VALIDATOR
9} from '@app/shared/form-validators/video-channel-validators'
10import { FormValidatorService } from '@app/shared/shared-forms'
6import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' 11import { VideoChannel, VideoChannelService } from '@app/shared/shared-main'
7import { ServerConfig, VideoChannelUpdate } from '@shared/models' 12import { ServerConfig, VideoChannelUpdate } from '@shared/models'
8import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' 13import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
@@ -23,7 +28,6 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE
23 constructor ( 28 constructor (
24 protected formValidatorService: FormValidatorService, 29 protected formValidatorService: FormValidatorService,
25 private authService: AuthService, 30 private authService: AuthService,
26 private videoChannelValidatorsService: VideoChannelValidatorsService,
27 private notifier: Notifier, 31 private notifier: Notifier,
28 private router: Router, 32 private router: Router,
29 private route: ActivatedRoute, 33 private route: ActivatedRoute,
@@ -39,9 +43,9 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE
39 .subscribe(config => this.serverConfig = config) 43 .subscribe(config => this.serverConfig = config)
40 44
41 this.buildForm({ 45 this.buildForm({
42 'display-name': this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME, 46 'display-name': VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
43 description: this.videoChannelValidatorsService.VIDEO_CHANNEL_DESCRIPTION, 47 description: VIDEO_CHANNEL_DESCRIPTION_VALIDATOR,
44 support: this.videoChannelValidatorsService.VIDEO_CHANNEL_SUPPORT, 48 support: VIDEO_CHANNEL_SUPPORT_VALIDATOR,
45 bulkVideosSupportUpdate: null 49 bulkVideosSupportUpdate: null
46 }) 50 })
47 51
diff --git a/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.ts b/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.ts
index 3bfffe2da..4c4436755 100644
--- a/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.ts
+++ b/client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.ts
@@ -1,6 +1,7 @@
1import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' 1import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
2import { AuthService, Notifier } from '@app/core' 2import { AuthService, Notifier } from '@app/core'
3import { FormReactive, FormValidatorService, VideoAcceptOwnershipValidatorsService } from '@app/shared/shared-forms' 3import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators'
4import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
4import { VideoChannelService, VideoOwnershipService } from '@app/shared/shared-main' 5import { VideoChannelService, VideoOwnershipService } from '@app/shared/shared-main'
5import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 6import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
6import { VideoChangeOwnership, VideoChannel } from '@shared/models' 7import { VideoChangeOwnership, VideoChannel } from '@shared/models'
@@ -23,7 +24,6 @@ export class MyAccountAcceptOwnershipComponent extends FormReactive implements O
23 24
24 constructor ( 25 constructor (
25 protected formValidatorService: FormValidatorService, 26 protected formValidatorService: FormValidatorService,
26 private videoChangeOwnershipValidatorsService: VideoAcceptOwnershipValidatorsService,
27 private videoOwnershipService: VideoOwnershipService, 27 private videoOwnershipService: VideoOwnershipService,
28 private notifier: Notifier, 28 private notifier: Notifier,
29 private authService: AuthService, 29 private authService: AuthService,
@@ -40,7 +40,7 @@ export class MyAccountAcceptOwnershipComponent extends FormReactive implements O
40 .subscribe(videoChannels => this.videoChannels = videoChannels.data) 40 .subscribe(videoChannels => this.videoChannels = videoChannels.data)
41 41
42 this.buildForm({ 42 this.buildForm({
43 channel: this.videoChangeOwnershipValidatorsService.CHANNEL 43 channel: OWNERSHIP_CHANGE_CHANNEL_VALIDATOR
44 }) 44 })
45 } 45 }
46 46
diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts
index 396936ef3..b2b7849c2 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts
+++ b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts
@@ -2,7 +2,8 @@ import { forkJoin } from 'rxjs'
2import { tap } from 'rxjs/operators' 2import { tap } from 'rxjs/operators'
3import { Component, OnInit } from '@angular/core' 3import { Component, OnInit } from '@angular/core'
4import { AuthService, ServerService, UserService } from '@app/core' 4import { AuthService, ServerService, UserService } from '@app/core'
5import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' 5import { USER_EMAIL_VALIDATOR, USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
6import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
6import { User } from '@shared/models' 7import { User } from '@shared/models'
7 8
8@Component({ 9@Component({
@@ -17,18 +18,17 @@ export class MyAccountChangeEmailComponent extends FormReactive implements OnIni
17 18
18 constructor ( 19 constructor (
19 protected formValidatorService: FormValidatorService, 20 protected formValidatorService: FormValidatorService,
20 private userValidatorsService: UserValidatorsService,
21 private authService: AuthService, 21 private authService: AuthService,
22 private userService: UserService, 22 private userService: UserService,
23 private serverService: ServerService 23 private serverService: ServerService
24 ) { 24 ) {
25 super() 25 super()
26 } 26 }
27 27
28 ngOnInit () { 28 ngOnInit () {
29 this.buildForm({ 29 this.buildForm({
30 'new-email': this.userValidatorsService.USER_EMAIL, 30 'new-email': USER_EMAIL_VALIDATOR,
31 'password': this.userValidatorsService.USER_PASSWORD 31 'password': USER_PASSWORD_VALIDATOR
32 }) 32 })
33 33
34 this.user = this.authService.getUser() 34 this.user = this.authService.getUser()
diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts
index 91fe4ec72..ba68bab32 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts
+++ b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts
@@ -1,7 +1,8 @@
1import { filter } from 'rxjs/operators' 1import { filter } from 'rxjs/operators'
2import { Component, OnInit } from '@angular/core' 2import { Component, OnInit } from '@angular/core'
3import { AuthService, Notifier, UserService } from '@app/core' 3import { AuthService, Notifier, UserService } from '@app/core'
4import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' 4import { USER_CONFIRM_PASSWORD_VALIDATOR, USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
5import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
5import { User } from '@shared/models' 6import { User } from '@shared/models'
6 7
7@Component({ 8@Component({
@@ -15,7 +16,6 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On
15 16
16 constructor ( 17 constructor (
17 protected formValidatorService: FormValidatorService, 18 protected formValidatorService: FormValidatorService,
18 private userValidatorsService: UserValidatorsService,
19 private notifier: Notifier, 19 private notifier: Notifier,
20 private authService: AuthService, 20 private authService: AuthService,
21 private userService: UserService 21 private userService: UserService
@@ -25,9 +25,9 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On
25 25
26 ngOnInit () { 26 ngOnInit () {
27 this.buildForm({ 27 this.buildForm({
28 'current-password': this.userValidatorsService.USER_PASSWORD, 28 'current-password': USER_PASSWORD_VALIDATOR,
29 'new-password': this.userValidatorsService.USER_PASSWORD, 29 'new-password': USER_PASSWORD_VALIDATOR,
30 'new-confirmed-password': this.userValidatorsService.USER_CONFIRM_PASSWORD 30 'new-confirmed-password': USER_CONFIRM_PASSWORD_VALIDATOR
31 }) 31 })
32 32
33 this.user = this.authService.getUser() 33 this.user = this.authService.getUser()
diff --git a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
index ed0984bf7..000a2c0ac 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
+++ b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
@@ -1,7 +1,8 @@
1import { Subject } from 'rxjs' 1import { Subject } from 'rxjs'
2import { Component, Input, OnInit } from '@angular/core' 2import { Component, Input, OnInit } from '@angular/core'
3import { Notifier, User, UserService } from '@app/core' 3import { Notifier, User, UserService } from '@app/core'
4import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' 4import { USER_DESCRIPTION_VALIDATOR, USER_DISPLAY_NAME_REQUIRED_VALIDATOR } from '@app/shared/form-validators/user-validators'
5import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
5 6
6@Component({ 7@Component({
7 selector: 'my-account-profile', 8 selector: 'my-account-profile',
@@ -16,17 +17,16 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit {
16 17
17 constructor ( 18 constructor (
18 protected formValidatorService: FormValidatorService, 19 protected formValidatorService: FormValidatorService,
19 private userValidatorsService: UserValidatorsService,
20 private notifier: Notifier, 20 private notifier: Notifier,
21 private userService: UserService 21 private userService: UserService
22 ) { 22 ) {
23 super() 23 super()
24 } 24 }
25 25
26 ngOnInit () { 26 ngOnInit () {
27 this.buildForm({ 27 this.buildForm({
28 'display-name': this.userValidatorsService.USER_DISPLAY_NAME_REQUIRED, 28 'display-name': USER_DISPLAY_NAME_REQUIRED_VALIDATOR,
29 description: this.userValidatorsService.USER_DESCRIPTION 29 description: USER_DESCRIPTION_VALIDATOR
30 }) 30 })
31 31
32 this.userInformationLoaded.subscribe(() => { 32 this.userInformationLoaded.subscribe(() => {
diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts
index 5427dc3a0..7a80aaa92 100644
--- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts
+++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts
@@ -2,7 +2,14 @@ import { Component, OnInit } from '@angular/core'
2import { Router } from '@angular/router' 2import { Router } from '@angular/router'
3import { AuthService, Notifier, ServerService } from '@app/core' 3import { AuthService, Notifier, ServerService } from '@app/core'
4import { populateAsyncUserVideoChannels } from '@app/helpers' 4import { populateAsyncUserVideoChannels } from '@app/helpers'
5import { FormValidatorService, VideoPlaylistValidatorsService } from '@app/shared/shared-forms' 5import {
6 setPlaylistChannelValidator,
7 VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
8 VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
9 VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
10 VIDEO_PLAYLIST_PRIVACY_VALIDATOR
11} from '@app/shared/form-validators/video-playlist-validators'
12import { FormValidatorService } from '@app/shared/shared-forms'
6import { VideoPlaylistService } from '@app/shared/shared-video-playlist' 13import { VideoPlaylistService } from '@app/shared/shared-video-playlist'
7import { VideoPlaylistCreate } from '@shared/models/videos/playlist/video-playlist-create.model' 14import { VideoPlaylistCreate } from '@shared/models/videos/playlist/video-playlist-create.model'
8import { VideoPlaylistPrivacy } from '@shared/models/videos/playlist/video-playlist-privacy.model' 15import { VideoPlaylistPrivacy } from '@shared/models/videos/playlist/video-playlist-privacy.model'
@@ -19,7 +26,6 @@ export class MyAccountVideoPlaylistCreateComponent extends MyAccountVideoPlaylis
19 constructor ( 26 constructor (
20 protected formValidatorService: FormValidatorService, 27 protected formValidatorService: FormValidatorService,
21 private authService: AuthService, 28 private authService: AuthService,
22 private videoPlaylistValidatorsService: VideoPlaylistValidatorsService,
23 private notifier: Notifier, 29 private notifier: Notifier,
24 private router: Router, 30 private router: Router,
25 private videoPlaylistService: VideoPlaylistService, 31 private videoPlaylistService: VideoPlaylistService,
@@ -30,15 +36,15 @@ export class MyAccountVideoPlaylistCreateComponent extends MyAccountVideoPlaylis
30 36
31 ngOnInit () { 37 ngOnInit () {
32 this.buildForm({ 38 this.buildForm({
33 displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME, 39 displayName: VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
34 privacy: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_PRIVACY, 40 privacy: VIDEO_PLAYLIST_PRIVACY_VALIDATOR,
35 description: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DESCRIPTION, 41 description: VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
36 videoChannelId: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_CHANNEL_ID, 42 videoChannelId: VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
37 thumbnailfile: null 43 thumbnailfile: null
38 }) 44 })
39 45
40 this.form.get('privacy').valueChanges.subscribe(privacy => { 46 this.form.get('privacy').valueChanges.subscribe(privacy => {
41 this.videoPlaylistValidatorsService.setChannelValidator(this.form.get('videoChannelId'), privacy) 47 setPlaylistChannelValidator(this.form.get('videoChannelId'), privacy)
42 }) 48 })
43 49
44 populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) 50 populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts
index 149d0d94f..fefc6d607 100644
--- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts
+++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts
@@ -4,7 +4,14 @@ import { Component, OnDestroy, OnInit } from '@angular/core'
4import { ActivatedRoute, Router } from '@angular/router' 4import { ActivatedRoute, Router } from '@angular/router'
5import { AuthService, Notifier, ServerService } from '@app/core' 5import { AuthService, Notifier, ServerService } from '@app/core'
6import { populateAsyncUserVideoChannels } from '@app/helpers' 6import { populateAsyncUserVideoChannels } from '@app/helpers'
7import { FormValidatorService, VideoPlaylistValidatorsService } from '@app/shared/shared-forms' 7import {
8 setPlaylistChannelValidator,
9 VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
10 VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
11 VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
12 VIDEO_PLAYLIST_PRIVACY_VALIDATOR
13} from '@app/shared/form-validators/video-playlist-validators'
14import { FormValidatorService } from '@app/shared/shared-forms'
8import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' 15import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
9import { VideoPlaylistUpdate } from '@shared/models' 16import { VideoPlaylistUpdate } from '@shared/models'
10import { MyAccountVideoPlaylistEdit } from './my-account-video-playlist-edit' 17import { MyAccountVideoPlaylistEdit } from './my-account-video-playlist-edit'
@@ -23,7 +30,6 @@ export class MyAccountVideoPlaylistUpdateComponent extends MyAccountVideoPlaylis
23 constructor ( 30 constructor (
24 protected formValidatorService: FormValidatorService, 31 protected formValidatorService: FormValidatorService,
25 private authService: AuthService, 32 private authService: AuthService,
26 private videoPlaylistValidatorsService: VideoPlaylistValidatorsService,
27 private notifier: Notifier, 33 private notifier: Notifier,
28 private router: Router, 34 private router: Router,
29 private route: ActivatedRoute, 35 private route: ActivatedRoute,
@@ -35,15 +41,15 @@ export class MyAccountVideoPlaylistUpdateComponent extends MyAccountVideoPlaylis
35 41
36 ngOnInit () { 42 ngOnInit () {
37 this.buildForm({ 43 this.buildForm({
38 displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME, 44 displayName: VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
39 privacy: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_PRIVACY, 45 privacy: VIDEO_PLAYLIST_PRIVACY_VALIDATOR,
40 description: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DESCRIPTION, 46 description: VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
41 videoChannelId: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_CHANNEL_ID, 47 videoChannelId: VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
42 thumbnailfile: null 48 thumbnailfile: null
43 }) 49 })
44 50
45 this.form.get('privacy').valueChanges.subscribe(privacy => { 51 this.form.get('privacy').valueChanges.subscribe(privacy => {
46 this.videoPlaylistValidatorsService.setChannelValidator(this.form.get('videoChannelId'), privacy) 52 setPlaylistChannelValidator(this.form.get('videoChannelId'), privacy)
47 }) 53 })
48 54
49 populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) 55 populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
diff --git a/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts b/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts
index edd691694..84237dee1 100644
--- a/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts
+++ b/client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts
@@ -1,6 +1,7 @@
1import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' 1import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
2import { Notifier, UserService } from '@app/core' 2import { Notifier, UserService } from '@app/core'
3import { FormReactive, FormValidatorService, VideoChangeOwnershipValidatorsService } from '@app/shared/shared-forms' 3import { OWNERSHIP_CHANGE_USERNAME_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators'
4import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
4import { Video, VideoOwnershipService } from '@app/shared/shared-main' 5import { Video, VideoOwnershipService } from '@app/shared/shared-main'
5import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 6import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
6 7
@@ -20,7 +21,6 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni
20 21
21 constructor ( 22 constructor (
22 protected formValidatorService: FormValidatorService, 23 protected formValidatorService: FormValidatorService,
23 private videoChangeOwnershipValidatorsService: VideoChangeOwnershipValidatorsService,
24 private videoOwnershipService: VideoOwnershipService, 24 private videoOwnershipService: VideoOwnershipService,
25 private notifier: Notifier, 25 private notifier: Notifier,
26 private userService: UserService, 26 private userService: UserService,
@@ -31,7 +31,7 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni
31 31
32 ngOnInit () { 32 ngOnInit () {
33 this.buildForm({ 33 this.buildForm({
34 username: this.videoChangeOwnershipValidatorsService.USERNAME 34 username: OWNERSHIP_CHANGE_USERNAME_VALIDATOR
35 }) 35 })
36 this.usernamePropositions = [] 36 this.usernamePropositions = []
37 } 37 }
diff --git a/client/src/app/+reset-password/reset-password.component.ts b/client/src/app/+reset-password/reset-password.component.ts
index 16e4f4090..ce9144170 100644
--- a/client/src/app/+reset-password/reset-password.component.ts
+++ b/client/src/app/+reset-password/reset-password.component.ts
@@ -1,7 +1,9 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { Notifier, UserService } from '@app/core' 3import { Notifier, UserService } from '@app/core'
4import { FormReactive, FormValidatorService, ResetPasswordValidatorsService, UserValidatorsService } from '@app/shared/shared-forms' 4import { RESET_PASSWORD_CONFIRM_VALIDATOR } from '@app/shared/form-validators/reset-password-validators'
5import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
6import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
5 7
6@Component({ 8@Component({
7 selector: 'my-login', 9 selector: 'my-login',
@@ -15,8 +17,6 @@ export class ResetPasswordComponent extends FormReactive implements OnInit {
15 17
16 constructor ( 18 constructor (
17 protected formValidatorService: FormValidatorService, 19 protected formValidatorService: FormValidatorService,
18 private resetPasswordValidatorsService: ResetPasswordValidatorsService,
19 private userValidatorsService: UserValidatorsService,
20 private userService: UserService, 20 private userService: UserService,
21 private notifier: Notifier, 21 private notifier: Notifier,
22 private router: Router, 22 private router: Router,
@@ -27,8 +27,8 @@ export class ResetPasswordComponent extends FormReactive implements OnInit {
27 27
28 ngOnInit () { 28 ngOnInit () {
29 this.buildForm({ 29 this.buildForm({
30 password: this.userValidatorsService.USER_PASSWORD, 30 password: USER_PASSWORD_VALIDATOR,
31 'password-confirm': this.resetPasswordValidatorsService.RESET_PASSWORD_CONFIRM 31 'password-confirm': RESET_PASSWORD_CONFIRM_VALIDATOR
32 }) 32 })
33 33
34 this.userId = this.route.snapshot.queryParams['userId'] 34 this.userId = this.route.snapshot.queryParams['userId']
diff --git a/client/src/app/+signup/+register/register-step-channel.component.ts b/client/src/app/+signup/+register/register-step-channel.component.ts
index 8a0120840..d965a7865 100644
--- a/client/src/app/+signup/+register/register-step-channel.component.ts
+++ b/client/src/app/+signup/+register/register-step-channel.component.ts
@@ -3,7 +3,8 @@ import { pairwise } from 'rxjs/operators'
3import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 3import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
4import { FormGroup } from '@angular/forms' 4import { FormGroup } from '@angular/forms'
5import { UserService } from '@app/core' 5import { UserService } from '@app/core'
6import { FormReactive, FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms' 6import { VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, VIDEO_CHANNEL_NAME_VALIDATOR } from '@app/shared/form-validators/video-channel-validators'
7import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
7 8
8@Component({ 9@Component({
9 selector: 'my-register-step-channel', 10 selector: 'my-register-step-channel',
@@ -16,8 +17,7 @@ export class RegisterStepChannelComponent extends FormReactive implements OnInit
16 17
17 constructor ( 18 constructor (
18 protected formValidatorService: FormValidatorService, 19 protected formValidatorService: FormValidatorService,
19 private userService: UserService, 20 private userService: UserService
20 private videoChannelValidatorsService: VideoChannelValidatorsService
21 ) { 21 ) {
22 super() 22 super()
23 } 23 }
@@ -28,8 +28,8 @@ export class RegisterStepChannelComponent extends FormReactive implements OnInit
28 28
29 ngOnInit () { 29 ngOnInit () {
30 this.buildForm({ 30 this.buildForm({
31 displayName: this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME, 31 displayName: VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
32 name: this.videoChannelValidatorsService.VIDEO_CHANNEL_NAME 32 name: VIDEO_CHANNEL_NAME_VALIDATOR
33 }) 33 })
34 34
35 setTimeout(() => this.formBuilt.emit(this.form)) 35 setTimeout(() => this.formBuilt.emit(this.form))
diff --git a/client/src/app/+signup/+register/register-step-user.component.ts b/client/src/app/+signup/+register/register-step-user.component.ts
index 3d9ab8b6b..65536568b 100644
--- a/client/src/app/+signup/+register/register-step-user.component.ts
+++ b/client/src/app/+signup/+register/register-step-user.component.ts
@@ -3,7 +3,14 @@ import { pairwise } from 'rxjs/operators'
3import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 3import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
4import { FormGroup } from '@angular/forms' 4import { FormGroup } from '@angular/forms'
5import { UserService } from '@app/core' 5import { UserService } from '@app/core'
6import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' 6import {
7 USER_DISPLAY_NAME_REQUIRED_VALIDATOR,
8 USER_EMAIL_VALIDATOR,
9 USER_PASSWORD_VALIDATOR,
10 USER_TERMS_VALIDATOR,
11 USER_USERNAME_VALIDATOR
12} from '@app/shared/form-validators/user-validators'
13import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
7 14
8@Component({ 15@Component({
9 selector: 'my-register-step-user', 16 selector: 'my-register-step-user',
@@ -19,8 +26,7 @@ export class RegisterStepUserComponent extends FormReactive implements OnInit {
19 26
20 constructor ( 27 constructor (
21 protected formValidatorService: FormValidatorService, 28 protected formValidatorService: FormValidatorService,
22 private userService: UserService, 29 private userService: UserService
23 private userValidatorsService: UserValidatorsService
24 ) { 30 ) {
25 super() 31 super()
26 } 32 }
@@ -31,11 +37,11 @@ export class RegisterStepUserComponent extends FormReactive implements OnInit {
31 37
32 ngOnInit () { 38 ngOnInit () {
33 this.buildForm({ 39 this.buildForm({
34 displayName: this.userValidatorsService.USER_DISPLAY_NAME_REQUIRED, 40 displayName: USER_DISPLAY_NAME_REQUIRED_VALIDATOR,
35 username: this.userValidatorsService.USER_USERNAME, 41 username: USER_USERNAME_VALIDATOR,
36 password: this.userValidatorsService.USER_PASSWORD, 42 password: USER_PASSWORD_VALIDATOR,
37 email: this.userValidatorsService.USER_EMAIL, 43 email: USER_EMAIL_VALIDATOR,
38 terms: this.userValidatorsService.USER_TERMS 44 terms: USER_TERMS_VALIDATOR
39 }) 45 })
40 46
41 setTimeout(() => this.formBuilt.emit(this.form)) 47 setTimeout(() => this.formBuilt.emit(this.form))
diff --git a/client/src/app/+signup/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.ts b/client/src/app/+signup/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.ts
index b26581d2b..830dd9962 100644
--- a/client/src/app/+signup/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.ts
+++ b/client/src/app/+signup/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.ts
@@ -1,6 +1,7 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { Notifier, RedirectService, ServerService, UserService } from '@app/core' 2import { Notifier, RedirectService, ServerService, UserService } from '@app/core'
3import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' 3import { USER_EMAIL_VALIDATOR } from '@app/shared/form-validators/user-validators'
4import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
4import { ServerConfig } from '@shared/models' 5import { ServerConfig } from '@shared/models'
5 6
6@Component({ 7@Component({
@@ -14,7 +15,6 @@ export class VerifyAccountAskSendEmailComponent extends FormReactive implements
14 15
15 constructor ( 16 constructor (
16 protected formValidatorService: FormValidatorService, 17 protected formValidatorService: FormValidatorService,
17 private userValidatorsService: UserValidatorsService,
18 private userService: UserService, 18 private userService: UserService,
19 private serverService: ServerService, 19 private serverService: ServerService,
20 private notifier: Notifier, 20 private notifier: Notifier,
@@ -33,7 +33,7 @@ export class VerifyAccountAskSendEmailComponent extends FormReactive implements
33 .subscribe(config => this.serverConfig = config) 33 .subscribe(config => this.serverConfig = config)
34 34
35 this.buildForm({ 35 this.buildForm({
36 'verify-email-email': this.userValidatorsService.USER_EMAIL 36 'verify-email-email': USER_EMAIL_VALIDATOR
37 }) 37 })
38 } 38 }
39 39
diff --git a/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts b/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts
index a90d04ce8..e48d16527 100644
--- a/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts
+++ b/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts
@@ -1,6 +1,7 @@
1import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' 1import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
2import { ServerService } from '@app/core' 2import { ServerService } from '@app/core'
3import { FormReactive, FormValidatorService, VideoCaptionsValidatorsService } from '@app/shared/shared-forms' 3import { VIDEO_CAPTION_FILE_VALIDATOR, VIDEO_CAPTION_LANGUAGE_VALIDATOR } from '@app/shared/form-validators/video-captions-validators'
4import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
4import { VideoCaptionEdit } from '@app/shared/shared-main' 5import { VideoCaptionEdit } from '@app/shared/shared-main'
5import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' 6import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
6import { ServerConfig, VideoConstant } from '@shared/models' 7import { ServerConfig, VideoConstant } from '@shared/models'
@@ -27,8 +28,7 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni
27 constructor ( 28 constructor (
28 protected formValidatorService: FormValidatorService, 29 protected formValidatorService: FormValidatorService,
29 private modalService: NgbModal, 30 private modalService: NgbModal,
30 private serverService: ServerService, 31 private serverService: ServerService
31 private videoCaptionsValidatorsService: VideoCaptionsValidatorsService
32 ) { 32 ) {
33 super() 33 super()
34 } 34 }
@@ -46,8 +46,8 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni
46 .subscribe(languages => this.videoCaptionLanguages = languages) 46 .subscribe(languages => this.videoCaptionLanguages = languages)
47 47
48 this.buildForm({ 48 this.buildForm({
49 language: this.videoCaptionsValidatorsService.VIDEO_CAPTION_LANGUAGE, 49 language: VIDEO_CAPTION_LANGUAGE_VALIDATOR,
50 captionfile: this.videoCaptionsValidatorsService.VIDEO_CAPTION_FILE 50 captionfile: VIDEO_CAPTION_FILE_VALIDATOR
51 }) 51 })
52 } 52 }
53 53
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
index 050b6d931..92d06aa12 100644
--- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
+++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
@@ -4,7 +4,20 @@ import { Component, Input, NgZone, OnDestroy, OnInit, ViewChild } from '@angular
4import { FormArray, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms' 4import { FormArray, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms'
5import { ServerService } from '@app/core' 5import { ServerService } from '@app/core'
6import { removeElementFromArray } from '@app/helpers' 6import { removeElementFromArray } from '@app/helpers'
7import { FormReactiveValidationMessages, FormValidatorService, SelectChannelItem, VideoValidatorsService } from '@app/shared/shared-forms' 7import {
8 VIDEO_CATEGORY_VALIDATOR,
9 VIDEO_CHANNEL_VALIDATOR,
10 VIDEO_DESCRIPTION_VALIDATOR,
11 VIDEO_LANGUAGE_VALIDATOR,
12 VIDEO_LICENCE_VALIDATOR,
13 VIDEO_NAME_VALIDATOR,
14 VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR,
15 VIDEO_PRIVACY_VALIDATOR,
16 VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR,
17 VIDEO_SUPPORT_VALIDATOR,
18 VIDEO_TAGS_ARRAY_VALIDATOR
19} from '@app/shared/form-validators/video-validators'
20import { FormReactiveValidationMessages, FormValidatorService, SelectChannelItem } from '@app/shared/shared-forms'
8import { InstanceService } from '@app/shared/shared-instance' 21import { InstanceService } from '@app/shared/shared-instance'
9import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main' 22import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main'
10import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' 23import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models'
@@ -57,7 +70,6 @@ export class VideoEditComponent implements OnInit, OnDestroy {
57 70
58 constructor ( 71 constructor (
59 private formValidatorService: FormValidatorService, 72 private formValidatorService: FormValidatorService,
60 private videoValidatorsService: VideoValidatorsService,
61 private videoService: VideoService, 73 private videoService: VideoService,
62 private serverService: ServerService, 74 private serverService: ServerService,
63 private instanceService: InstanceService, 75 private instanceService: InstanceService,
@@ -84,22 +96,22 @@ export class VideoEditComponent implements OnInit, OnDestroy {
84 tags: [] 96 tags: []
85 } 97 }
86 const obj: any = { 98 const obj: any = {
87 name: this.videoValidatorsService.VIDEO_NAME, 99 name: VIDEO_NAME_VALIDATOR,
88 privacy: this.videoValidatorsService.VIDEO_PRIVACY, 100 privacy: VIDEO_PRIVACY_VALIDATOR,
89 channelId: this.videoValidatorsService.VIDEO_CHANNEL, 101 channelId: VIDEO_CHANNEL_VALIDATOR,
90 nsfw: null, 102 nsfw: null,
91 commentsEnabled: null, 103 commentsEnabled: null,
92 downloadEnabled: null, 104 downloadEnabled: null,
93 waitTranscoding: null, 105 waitTranscoding: null,
94 category: this.videoValidatorsService.VIDEO_CATEGORY, 106 category: VIDEO_CATEGORY_VALIDATOR,
95 licence: this.videoValidatorsService.VIDEO_LICENCE, 107 licence: VIDEO_LICENCE_VALIDATOR,
96 language: this.videoValidatorsService.VIDEO_LANGUAGE, 108 language: VIDEO_LANGUAGE_VALIDATOR,
97 description: this.videoValidatorsService.VIDEO_DESCRIPTION, 109 description: VIDEO_DESCRIPTION_VALIDATOR,
98 tags: this.videoValidatorsService.VIDEO_TAGS_ARRAY, 110 tags: VIDEO_TAGS_ARRAY_VALIDATOR,
99 previewfile: null, 111 previewfile: null,
100 support: this.videoValidatorsService.VIDEO_SUPPORT, 112 support: VIDEO_SUPPORT_VALIDATOR,
101 schedulePublicationAt: this.videoValidatorsService.VIDEO_SCHEDULE_PUBLICATION_AT, 113 schedulePublicationAt: VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR,
102 originallyPublishedAt: this.videoValidatorsService.VIDEO_ORIGINALLY_PUBLISHED_AT 114 originallyPublishedAt: VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR
103 } 115 }
104 116
105 this.formValidatorService.updateForm( 117 this.formValidatorService.updateForm(
diff --git a/client/src/app/+videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/+videos/+video-watch/comment/video-comment-add.component.ts
index fa20ec3b9..c1d0032cc 100644
--- a/client/src/app/+videos/+video-watch/comment/video-comment-add.component.ts
+++ b/client/src/app/+videos/+video-watch/comment/video-comment-add.component.ts
@@ -2,7 +2,8 @@ import { Observable } from 'rxjs'
2import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core' 2import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core'
3import { Router } from '@angular/router' 3import { Router } from '@angular/router'
4import { Notifier, User } from '@app/core' 4import { Notifier, User } from '@app/core'
5import { FormReactive, FormValidatorService, VideoCommentValidatorsService } from '@app/shared/shared-forms' 5import { VIDEO_COMMENT_TEXT_VALIDATOR } from '@app/shared/form-validators/video-comment-validators'
6import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
6import { Video } from '@app/shared/shared-main' 7import { Video } from '@app/shared/shared-main'
7import { VideoComment, VideoCommentService } from '@app/shared/shared-video-comment' 8import { VideoComment, VideoCommentService } from '@app/shared/shared-video-comment'
8import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 9import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
@@ -33,7 +34,6 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
33 34
34 constructor ( 35 constructor (
35 protected formValidatorService: FormValidatorService, 36 protected formValidatorService: FormValidatorService,
36 private videoCommentValidatorsService: VideoCommentValidatorsService,
37 private notifier: Notifier, 37 private notifier: Notifier,
38 private videoCommentService: VideoCommentService, 38 private videoCommentService: VideoCommentService,
39 private modalService: NgbModal, 39 private modalService: NgbModal,
@@ -50,7 +50,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
50 50
51 ngOnInit () { 51 ngOnInit () {
52 this.buildForm({ 52 this.buildForm({
53 text: this.videoCommentValidatorsService.VIDEO_COMMENT_TEXT 53 text: VIDEO_COMMENT_TEXT_VALIDATOR
54 }) 54 })
55 55
56 if (this.user) { 56 if (this.user) {
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()