]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
We don't need services anymore for validators
authorChocobozzz <me@florianbigard.com>
Mon, 17 Aug 2020 09:47:04 +0000 (11:47 +0200)
committerChocobozzz <chocobozzz@cpy.re>
Mon, 17 Aug 2020 13:12:55 +0000 (15:12 +0200)
70 files changed:
client/src/app/+about/about-instance/contact-admin-modal.component.ts
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts
client/src/app/+admin/users/user-edit/user-create.component.ts
client/src/app/+admin/users/user-edit/user-password.component.ts
client/src/app/+admin/users/user-edit/user-update.component.ts
client/src/app/+login/login.component.ts
client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-create.component.ts
client/src/app/+my-account/+my-account-video-channels/my-account-video-channel-update.component.ts
client/src/app/+my-account/my-account-ownership/my-account-accept-ownership/my-account-accept-ownership.component.ts
client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts
client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts
client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component.ts
client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component.ts
client/src/app/+my-account/my-account-videos/video-change-ownership/video-change-ownership.component.ts
client/src/app/+reset-password/reset-password.component.ts
client/src/app/+signup/+register/register-step-channel.component.ts
client/src/app/+signup/+register/register-step-user.component.ts
client/src/app/+signup/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.ts
client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts
client/src/app/+videos/+video-edit/shared/video-edit.component.ts
client/src/app/+videos/+video-watch/comment/video-comment-add.component.ts
client/src/app/shared/form-validators/abuse-validators.ts [new file with mode: 0644]
client/src/app/shared/form-validators/batch-domains-validators.ts [new file with mode: 0644]
client/src/app/shared/form-validators/custom-config-validators.ts [new file with mode: 0644]
client/src/app/shared/form-validators/form-validator.model.ts [new file with mode: 0644]
client/src/app/shared/form-validators/host.ts [moved from client/src/app/shared/shared-forms/form-validators/host.ts with 100% similarity]
client/src/app/shared/form-validators/index.ts [new file with mode: 0644]
client/src/app/shared/form-validators/instance-validators.ts [new file with mode: 0644]
client/src/app/shared/form-validators/login-validators.ts [new file with mode: 0644]
client/src/app/shared/form-validators/reset-password-validators.ts [new file with mode: 0644]
client/src/app/shared/form-validators/user-validators.ts [new file with mode: 0644]
client/src/app/shared/form-validators/video-block-validators.ts [new file with mode: 0644]
client/src/app/shared/form-validators/video-captions-validators.ts [new file with mode: 0644]
client/src/app/shared/form-validators/video-channel-validators.ts [new file with mode: 0644]
client/src/app/shared/form-validators/video-comment-validators.ts [new file with mode: 0644]
client/src/app/shared/form-validators/video-ownership-change-validators.ts [new file with mode: 0644]
client/src/app/shared/form-validators/video-playlist-validators.ts [new file with mode: 0644]
client/src/app/shared/form-validators/video-validators.ts [new file with mode: 0644]
client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts
client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts
client/src/app/shared/shared-forms/form-reactive.ts
client/src/app/shared/shared-forms/form-validator.service.ts [moved from client/src/app/shared/shared-forms/form-validators/form-validator.service.ts with 88% similarity]
client/src/app/shared/shared-forms/form-validators/abuse-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/batch-domains-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/custom-config-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/index.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/instance-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/login-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/reset-password-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/user-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/video-accept-ownership-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/video-block-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/video-captions-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/video-change-ownership-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/video-channel-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/video-comment-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/video-playlist-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/form-validators/video-validators.service.ts [deleted file]
client/src/app/shared/shared-forms/index.ts
client/src/app/shared/shared-forms/shared-form.module.ts
client/src/app/shared/shared-moderation/batch-domains-modal.component.ts
client/src/app/shared/shared-moderation/report-modals/account-report.component.ts
client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts
client/src/app/shared/shared-moderation/report-modals/video-report.component.ts
client/src/app/shared/shared-moderation/user-ban-modal.component.ts
client/src/app/shared/shared-moderation/video-block.component.ts
client/src/app/shared/shared-user-subscription/remote-subscribe.component.ts
client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts

index 215e281bb5fcf5ee352bb3d6715782236f7fa43b..11e442f6bc0ca7d8cf308e0f484c890f0ce5ed08 100644 (file)
@@ -1,6 +1,12 @@
 import { Component, OnInit, ViewChild } from '@angular/core'
 import { Notifier, ServerService } from '@app/core'
-import { FormReactive, FormValidatorService, InstanceValidatorsService } from '@app/shared/shared-forms'
+import {
+  BODY_VALIDATOR,
+  FROM_EMAIL_VALIDATOR,
+  FROM_NAME_VALIDATOR,
+  SUBJECT_VALIDATOR
+} from '@app/shared/form-validators/instance-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { InstanceService } from '@app/shared/shared-instance'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
@@ -22,7 +28,6 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit {
   constructor (
     protected formValidatorService: FormValidatorService,
     private modalService: NgbModal,
-    private instanceValidatorsService: InstanceValidatorsService,
     private instanceService: InstanceService,
     private serverService: ServerService,
     private notifier: Notifier
@@ -40,10 +45,10 @@ export class ContactAdminModalComponent extends FormReactive implements OnInit {
         .subscribe(config => this.serverConfig = config)
 
     this.buildForm({
-      fromName: this.instanceValidatorsService.FROM_NAME,
-      fromEmail: this.instanceValidatorsService.FROM_EMAIL,
-      subject: this.instanceValidatorsService.SUBJECT,
-      body: this.instanceValidatorsService.BODY
+      fromName: FROM_NAME_VALIDATOR,
+      fromEmail: FROM_EMAIL_VALIDATOR,
+      subject: SUBJECT_VALIDATOR,
+      body: BODY_VALIDATOR
     })
   }
 
index 3a60b144f7f738bdf78e30b449973da2f4a56875..78e9dd5e5e8a28467434db09711c0a9b6c4b550b 100644 (file)
@@ -5,12 +5,19 @@ import { ConfigService } from '@app/+admin/config/shared/config.service'
 import { Notifier } from '@app/core'
 import { ServerService } from '@app/core/server/server.service'
 import {
-  CustomConfigValidatorsService,
-  FormReactive,
-  FormValidatorService,
-  SelectOptionsItem,
-  UserValidatorsService
-} from '@app/shared/shared-forms'
+  ADMIN_EMAIL_VALIDATOR,
+  CACHE_CAPTIONS_SIZE_VALIDATOR,
+  CACHE_PREVIEWS_SIZE_VALIDATOR,
+  INDEX_URL_VALIDATOR,
+  INSTANCE_NAME_VALIDATOR,
+  INSTANCE_SHORT_DESCRIPTION_VALIDATOR,
+  SEARCH_INDEX_URL_VALIDATOR,
+  SERVICES_TWITTER_USERNAME_VALIDATOR,
+  SIGNUP_LIMIT_VALIDATOR,
+  TRANSCODING_THREADS_VALIDATOR
+} from '@app/shared/form-validators/custom-config-validators'
+import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService, SelectOptionsItem } from '@app/shared/shared-forms'
 import { NgbNav } from '@ng-bootstrap/ng-bootstrap'
 import { CustomConfig, ServerConfig } from '@shared/models'
 
@@ -37,8 +44,6 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
   constructor (
     private viewportScroller: ViewportScroller,
     protected formValidatorService: FormValidatorService,
-    private customConfigValidatorsService: CustomConfigValidatorsService,
-    private userValidatorsService: UserValidatorsService,
     private notifier: Notifier,
     private configService: ConfigService,
     private serverService: ServerService
@@ -110,8 +115,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
 
     const formGroupData: { [key in keyof CustomConfig ]: any } = {
       instance: {
-        name: this.customConfigValidatorsService.INSTANCE_NAME,
-        shortDescription: this.customConfigValidatorsService.INSTANCE_SHORT_DESCRIPTION,
+        name: INSTANCE_NAME_VALIDATOR,
+        shortDescription: INSTANCE_SHORT_DESCRIPTION_VALIDATOR,
         description: null,
 
         isNSFW: false,
@@ -143,21 +148,21 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
       },
       services: {
         twitter: {
-          username: this.customConfigValidatorsService.SERVICES_TWITTER_USERNAME,
+          username: SERVICES_TWITTER_USERNAME_VALIDATOR,
           whitelisted: null
         }
       },
       cache: {
         previews: {
-          size: this.customConfigValidatorsService.CACHE_PREVIEWS_SIZE
+          size: CACHE_PREVIEWS_SIZE_VALIDATOR
         },
         captions: {
-          size: this.customConfigValidatorsService.CACHE_CAPTIONS_SIZE
+          size: CACHE_CAPTIONS_SIZE_VALIDATOR
         }
       },
       signup: {
         enabled: null,
-        limit: this.customConfigValidatorsService.SIGNUP_LIMIT,
+        limit: SIGNUP_LIMIT_VALIDATOR,
         requiresEmailVerification: null
       },
       import: {
@@ -171,18 +176,18 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
         }
       },
       admin: {
-        email: this.customConfigValidatorsService.ADMIN_EMAIL
+        email: ADMIN_EMAIL_VALIDATOR
       },
       contactForm: {
         enabled: null
       },
       user: {
-        videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA,
-        videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY
+        videoQuota: USER_VIDEO_QUOTA_VALIDATOR,
+        videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR
       },
       transcoding: {
         enabled: null,
-        threads: this.customConfigValidatorsService.TRANSCODING_THREADS,
+        threads: TRANSCODING_THREADS_VALIDATOR,
         allowAdditionalExtensions: null,
         allowAudioFiles: null,
         resolutions: {},
@@ -213,7 +218,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
           },
           autoFollowIndex: {
             enabled: null,
-            indexUrl: this.customConfigValidatorsService.INDEX_URL
+            indexUrl: INDEX_URL_VALIDATOR
           }
         }
       },
@@ -230,7 +235,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A
         },
         searchIndex: {
           enabled: null,
-          url: this.customConfigValidatorsService.SEARCH_INDEX_URL,
+          url: SEARCH_INDEX_URL_VALIDATOR,
           disableLocalSearch: null,
           isDefaultSearch: null
         }
index a33f0169106ae99a50475aebcfa530eac13857f5..1acaf9674ecd2fd18235f24354f09bda51a4e6ba 100644 (file)
@@ -3,7 +3,8 @@ import { map, switchMap } from 'rxjs/operators'
 import { Component, OnDestroy, OnInit } from '@angular/core'
 import { ActivatedRoute } from '@angular/router'
 import { Notifier } from '@app/core'
-import { BuildFormArgument, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { BuildFormArgument } from '@app/shared/form-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { PeerTubePlugin, RegisterServerSettingOptions } from '@shared/models'
 import { PluginApiService } from '../shared/plugin-api.service'
 
index 36d71a9273248634349c22013a6c325fb658115d..d0aac1cb93f9185f2d9c6b288b47c9c0c9cc3215 100644 (file)
@@ -2,7 +2,17 @@ import { Component, OnInit } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
 import { ConfigService } from '@app/+admin/config/shared/config.service'
 import { AuthService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
-import { FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import {
+  USER_CHANNEL_NAME_VALIDATOR,
+  USER_EMAIL_VALIDATOR,
+  USER_PASSWORD_OPTIONAL_VALIDATOR,
+  USER_PASSWORD_VALIDATOR,
+  USER_ROLE_VALIDATOR,
+  USER_USERNAME_VALIDATOR,
+  USER_VIDEO_QUOTA_DAILY_VALIDATOR,
+  USER_VIDEO_QUOTA_VALIDATOR
+} from '@app/shared/form-validators/user-validators'
+import { FormValidatorService } from '@app/shared/shared-forms'
 import { UserCreate, UserRole } from '@shared/models'
 import { UserEdit } from './user-edit'
 
@@ -20,7 +30,6 @@ export class UserCreateComponent extends UserEdit implements OnInit {
     protected configService: ConfigService,
     protected screenService: ScreenService,
     protected auth: AuthService,
-    private userValidatorsService: UserValidatorsService,
     private route: ActivatedRoute,
     private router: Router,
     private notifier: Notifier,
@@ -41,13 +50,13 @@ export class UserCreateComponent extends UserEdit implements OnInit {
     }
 
     this.buildForm({
-      username: this.userValidatorsService.USER_USERNAME,
-      channelName: this.userValidatorsService.USER_CHANNEL_NAME,
-      email: this.userValidatorsService.USER_EMAIL,
-      password: this.isPasswordOptional() ? this.userValidatorsService.USER_PASSWORD_OPTIONAL : this.userValidatorsService.USER_PASSWORD,
-      role: this.userValidatorsService.USER_ROLE,
-      videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA,
-      videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY,
+      username: USER_USERNAME_VALIDATOR,
+      channelName: USER_CHANNEL_NAME_VALIDATOR,
+      email: USER_EMAIL_VALIDATOR,
+      password: this.isPasswordOptional() ? USER_PASSWORD_OPTIONAL_VALIDATOR : USER_PASSWORD_VALIDATOR,
+      role: USER_ROLE_VALIDATOR,
+      videoQuota: USER_VIDEO_QUOTA_VALIDATOR,
+      videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR,
       byPassAutoBlock: null
     }, defaultValues)
   }
index 25f13495aa830730db9c505112eff83d3933cbf3..05d52b17f0679db2853deda66db76122d7a7c09a 100644 (file)
@@ -1,6 +1,7 @@
 import { Component, Input, OnInit } from '@angular/core'
 import { Notifier, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { UserUpdate } from '@shared/models'
 
 @Component({
@@ -17,7 +18,6 @@ export class UserPasswordComponent extends FormReactive implements OnInit {
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private userValidatorsService: UserValidatorsService,
     private notifier: Notifier,
     private userService: UserService
     ) {
@@ -26,7 +26,7 @@ export class UserPasswordComponent extends FormReactive implements OnInit {
 
   ngOnInit () {
     this.buildForm({
-      password: this.userValidatorsService.USER_PASSWORD
+      password: USER_PASSWORD_VALIDATOR
     })
   }
 
index 55bc7290e5930472d32ad16b5fa9cfc774d9306c..e16f66a2baecace4875ee9f71d5dd0edbdb19886 100644 (file)
@@ -3,7 +3,13 @@ import { Component, OnDestroy, OnInit } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
 import { ConfigService } from '@app/+admin/config/shared/config.service'
 import { AuthService, Notifier, ScreenService, ServerService, User, UserService } from '@app/core'
-import { FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import {
+  USER_EMAIL_VALIDATOR,
+  USER_ROLE_VALIDATOR,
+  USER_VIDEO_QUOTA_DAILY_VALIDATOR,
+  USER_VIDEO_QUOTA_VALIDATOR
+} from '@app/shared/form-validators/user-validators'
+import { FormValidatorService } from '@app/shared/shared-forms'
 import { User as UserType, UserAdminFlag, UserRole, UserUpdate } from '@shared/models'
 import { UserEdit } from './user-edit'
 
@@ -23,7 +29,6 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
     protected configService: ConfigService,
     protected screenService: ScreenService,
     protected auth: AuthService,
-    private userValidatorsService: UserValidatorsService,
     private route: ActivatedRoute,
     private router: Router,
     private notifier: Notifier,
@@ -44,10 +49,10 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
     }
 
     this.buildForm({
-      email: this.userValidatorsService.USER_EMAIL,
-      role: this.userValidatorsService.USER_ROLE,
-      videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA,
-      videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY,
+      email: USER_EMAIL_VALIDATOR,
+      role: USER_ROLE_VALIDATOR,
+      videoQuota: USER_VIDEO_QUOTA_VALIDATOR,
+      videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR,
       byPassAutoBlock: null
     }, defaultValues)
 
index e9336172e8b8e5f904d80479999ed745d3b27bd4..351750453285c2927966714b61f73ea62c756cc2 100644 (file)
@@ -3,7 +3,8 @@ import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angula
 import { ActivatedRoute } from '@angular/router'
 import { AuthService, Notifier, RedirectService, UserService } from '@app/core'
 import { HooksService } from '@app/core/plugins/hooks.service'
-import { FormReactive, FormValidatorService, LoginValidatorsService } from '@app/shared/shared-forms'
+import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
 import { RegisteredExternalAuthConfig, ServerConfig } from '@shared/models'
 
@@ -31,7 +32,6 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
     protected formValidatorService: FormValidatorService,
     private route: ActivatedRoute,
     private modalService: NgbModal,
-    private loginValidatorsService: LoginValidatorsService,
     private authService: AuthService,
     private userService: UserService,
     private redirectService: RedirectService,
@@ -65,8 +65,8 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
     }
 
     this.buildForm({
-      username: this.loginValidatorsService.LOGIN_USERNAME,
-      password: this.loginValidatorsService.LOGIN_PASSWORD
+      username: LOGIN_USERNAME_VALIDATOR,
+      password: LOGIN_PASSWORD_VALIDATOR
     })
   }
 
index 5c438c3bf537a7de1b00c3455ddd0f127cda2820..e2ea87fb8a74ab40d17da8ad1b9231768e7d08e8 100644 (file)
@@ -1,7 +1,13 @@
 import { Component, OnInit } from '@angular/core'
 import { Router } from '@angular/router'
 import { AuthService, Notifier } from '@app/core'
-import { FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms'
+import {
+  VIDEO_CHANNEL_DESCRIPTION_VALIDATOR,
+  VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
+  VIDEO_CHANNEL_NAME_VALIDATOR,
+  VIDEO_CHANNEL_SUPPORT_VALIDATOR
+} from '@app/shared/form-validators/video-channel-validators'
+import { FormValidatorService } from '@app/shared/shared-forms'
 import { VideoChannelService } from '@app/shared/shared-main'
 import { VideoChannelCreate } from '@shared/models'
 import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
@@ -17,7 +23,6 @@ export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelE
   constructor (
     protected formValidatorService: FormValidatorService,
     private authService: AuthService,
-    private videoChannelValidatorsService: VideoChannelValidatorsService,
     private notifier: Notifier,
     private router: Router,
     private videoChannelService: VideoChannelService
@@ -31,10 +36,10 @@ export class MyAccountVideoChannelCreateComponent extends MyAccountVideoChannelE
 
   ngOnInit () {
     this.buildForm({
-      name: this.videoChannelValidatorsService.VIDEO_CHANNEL_NAME,
-      'display-name': this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME,
-      description: this.videoChannelValidatorsService.VIDEO_CHANNEL_DESCRIPTION,
-      support: this.videoChannelValidatorsService.VIDEO_CHANNEL_SUPPORT
+      name: VIDEO_CHANNEL_NAME_VALIDATOR,
+      'display-name': VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
+      description: VIDEO_CHANNEL_DESCRIPTION_VALIDATOR,
+      support: VIDEO_CHANNEL_SUPPORT_VALIDATOR
     })
   }
 
index 485521dcc2b43c2e1baef938ba6cb251739212c4..01659b8daddd0251d4f326f3c87533daaf0ebea8 100644 (file)
@@ -2,7 +2,12 @@ import { Subscription } from 'rxjs'
 import { Component, OnDestroy, OnInit } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
 import { AuthService, Notifier, ServerService } from '@app/core'
-import { FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms'
+import {
+  VIDEO_CHANNEL_DESCRIPTION_VALIDATOR,
+  VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
+  VIDEO_CHANNEL_SUPPORT_VALIDATOR
+} from '@app/shared/form-validators/video-channel-validators'
+import { FormValidatorService } from '@app/shared/shared-forms'
 import { VideoChannel, VideoChannelService } from '@app/shared/shared-main'
 import { ServerConfig, VideoChannelUpdate } from '@shared/models'
 import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
@@ -23,7 +28,6 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE
   constructor (
     protected formValidatorService: FormValidatorService,
     private authService: AuthService,
-    private videoChannelValidatorsService: VideoChannelValidatorsService,
     private notifier: Notifier,
     private router: Router,
     private route: ActivatedRoute,
@@ -39,9 +43,9 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE
         .subscribe(config => this.serverConfig = config)
 
     this.buildForm({
-      'display-name': this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME,
-      description: this.videoChannelValidatorsService.VIDEO_CHANNEL_DESCRIPTION,
-      support: this.videoChannelValidatorsService.VIDEO_CHANNEL_SUPPORT,
+      'display-name': VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
+      description: VIDEO_CHANNEL_DESCRIPTION_VALIDATOR,
+      support: VIDEO_CHANNEL_SUPPORT_VALIDATOR,
       bulkVideosSupportUpdate: null
     })
 
index 3bfffe2da61770dc56f1822df774041e68f1d293..4c44367559968a92d85789c07d6ec54974ca54c0 100644 (file)
@@ -1,6 +1,7 @@
 import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
 import { AuthService, Notifier } from '@app/core'
-import { FormReactive, FormValidatorService, VideoAcceptOwnershipValidatorsService } from '@app/shared/shared-forms'
+import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { VideoChannelService, VideoOwnershipService } from '@app/shared/shared-main'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { VideoChangeOwnership, VideoChannel } from '@shared/models'
@@ -23,7 +24,6 @@ export class MyAccountAcceptOwnershipComponent extends FormReactive implements O
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private videoChangeOwnershipValidatorsService: VideoAcceptOwnershipValidatorsService,
     private videoOwnershipService: VideoOwnershipService,
     private notifier: Notifier,
     private authService: AuthService,
@@ -40,7 +40,7 @@ export class MyAccountAcceptOwnershipComponent extends FormReactive implements O
       .subscribe(videoChannels => this.videoChannels = videoChannels.data)
 
     this.buildForm({
-      channel: this.videoChangeOwnershipValidatorsService.CHANNEL
+      channel: OWNERSHIP_CHANGE_CHANNEL_VALIDATOR
     })
   }
 
index 396936ef3927b248c44ab16557a9674c8f109c2a..b2b7849c24052d406c3d9baac2bfcb40242b2b81 100644 (file)
@@ -2,7 +2,8 @@ import { forkJoin } from 'rxjs'
 import { tap } from 'rxjs/operators'
 import { Component, OnInit } from '@angular/core'
 import { AuthService, ServerService, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import { USER_EMAIL_VALIDATOR, USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { User } from '@shared/models'
 
 @Component({
@@ -17,18 +18,17 @@ export class MyAccountChangeEmailComponent extends FormReactive implements OnIni
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private userValidatorsService: UserValidatorsService,
     private authService: AuthService,
     private userService: UserService,
     private serverService: ServerService
-    ) {
+  ) {
     super()
   }
 
   ngOnInit () {
     this.buildForm({
-      'new-email': this.userValidatorsService.USER_EMAIL,
-      'password': this.userValidatorsService.USER_PASSWORD
+      'new-email': USER_EMAIL_VALIDATOR,
+      'password': USER_PASSWORD_VALIDATOR
     })
 
     this.user = this.authService.getUser()
index 91fe4ec72472beec3d2fc414ba66f479ed9291ef..ba68bab32dec089fef63fb1d13b7c15c3a3e36bc 100644 (file)
@@ -1,7 +1,8 @@
 import { filter } from 'rxjs/operators'
 import { Component, OnInit } from '@angular/core'
 import { AuthService, Notifier, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import { USER_CONFIRM_PASSWORD_VALIDATOR, USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { User } from '@shared/models'
 
 @Component({
@@ -15,7 +16,6 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private userValidatorsService: UserValidatorsService,
     private notifier: Notifier,
     private authService: AuthService,
     private userService: UserService
@@ -25,9 +25,9 @@ export class MyAccountChangePasswordComponent extends FormReactive implements On
 
   ngOnInit () {
     this.buildForm({
-      'current-password': this.userValidatorsService.USER_PASSWORD,
-      'new-password': this.userValidatorsService.USER_PASSWORD,
-      'new-confirmed-password': this.userValidatorsService.USER_CONFIRM_PASSWORD
+      'current-password': USER_PASSWORD_VALIDATOR,
+      'new-password': USER_PASSWORD_VALIDATOR,
+      'new-confirmed-password': USER_CONFIRM_PASSWORD_VALIDATOR
     })
 
     this.user = this.authService.getUser()
index ed0984bf7d780250af74690944d2f3e02d506d1a..000a2c0ac73b4b84f6ab7399d0399c9abe24eaa6 100644 (file)
@@ -1,7 +1,8 @@
 import { Subject } from 'rxjs'
 import { Component, Input, OnInit } from '@angular/core'
 import { Notifier, User, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import { USER_DESCRIPTION_VALIDATOR, USER_DISPLAY_NAME_REQUIRED_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 
 @Component({
   selector: 'my-account-profile',
@@ -16,17 +17,16 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit {
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private userValidatorsService: UserValidatorsService,
     private notifier: Notifier,
     private userService: UserService
-    ) {
+  ) {
     super()
   }
 
   ngOnInit () {
     this.buildForm({
-      'display-name': this.userValidatorsService.USER_DISPLAY_NAME_REQUIRED,
-      description: this.userValidatorsService.USER_DESCRIPTION
+      'display-name': USER_DISPLAY_NAME_REQUIRED_VALIDATOR,
+      description: USER_DESCRIPTION_VALIDATOR
     })
 
     this.userInformationLoaded.subscribe(() => {
index 5427dc3a01ff81f324d7c42feefafffadf33b5a6..7a80aaa92c369022d0fddb6c31d3effa14e76ab9 100644 (file)
@@ -2,7 +2,14 @@ import { Component, OnInit } from '@angular/core'
 import { Router } from '@angular/router'
 import { AuthService, Notifier, ServerService } from '@app/core'
 import { populateAsyncUserVideoChannels } from '@app/helpers'
-import { FormValidatorService, VideoPlaylistValidatorsService } from '@app/shared/shared-forms'
+import {
+  setPlaylistChannelValidator,
+  VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
+  VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
+  VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
+  VIDEO_PLAYLIST_PRIVACY_VALIDATOR
+} from '@app/shared/form-validators/video-playlist-validators'
+import { FormValidatorService } from '@app/shared/shared-forms'
 import { VideoPlaylistService } from '@app/shared/shared-video-playlist'
 import { VideoPlaylistCreate } from '@shared/models/videos/playlist/video-playlist-create.model'
 import { VideoPlaylistPrivacy } from '@shared/models/videos/playlist/video-playlist-privacy.model'
@@ -19,7 +26,6 @@ export class MyAccountVideoPlaylistCreateComponent extends MyAccountVideoPlaylis
   constructor (
     protected formValidatorService: FormValidatorService,
     private authService: AuthService,
-    private videoPlaylistValidatorsService: VideoPlaylistValidatorsService,
     private notifier: Notifier,
     private router: Router,
     private videoPlaylistService: VideoPlaylistService,
@@ -30,15 +36,15 @@ export class MyAccountVideoPlaylistCreateComponent extends MyAccountVideoPlaylis
 
   ngOnInit () {
     this.buildForm({
-      displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME,
-      privacy: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_PRIVACY,
-      description: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DESCRIPTION,
-      videoChannelId: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_CHANNEL_ID,
+      displayName: VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
+      privacy: VIDEO_PLAYLIST_PRIVACY_VALIDATOR,
+      description: VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
+      videoChannelId: VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
       thumbnailfile: null
     })
 
     this.form.get('privacy').valueChanges.subscribe(privacy => {
-      this.videoPlaylistValidatorsService.setChannelValidator(this.form.get('videoChannelId'), privacy)
+      setPlaylistChannelValidator(this.form.get('videoChannelId'), privacy)
     })
 
     populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
index 149d0d94f6af0436f11dd04ebf79ab40dce83168..fefc6d607ebc5abf42259318c63c95afba6e67ad 100644 (file)
@@ -4,7 +4,14 @@ import { Component, OnDestroy, OnInit } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
 import { AuthService, Notifier, ServerService } from '@app/core'
 import { populateAsyncUserVideoChannels } from '@app/helpers'
-import { FormValidatorService, VideoPlaylistValidatorsService } from '@app/shared/shared-forms'
+import {
+  setPlaylistChannelValidator,
+  VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
+  VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
+  VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
+  VIDEO_PLAYLIST_PRIVACY_VALIDATOR
+} from '@app/shared/form-validators/video-playlist-validators'
+import { FormValidatorService } from '@app/shared/shared-forms'
 import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
 import { VideoPlaylistUpdate } from '@shared/models'
 import { MyAccountVideoPlaylistEdit } from './my-account-video-playlist-edit'
@@ -23,7 +30,6 @@ export class MyAccountVideoPlaylistUpdateComponent extends MyAccountVideoPlaylis
   constructor (
     protected formValidatorService: FormValidatorService,
     private authService: AuthService,
-    private videoPlaylistValidatorsService: VideoPlaylistValidatorsService,
     private notifier: Notifier,
     private router: Router,
     private route: ActivatedRoute,
@@ -35,15 +41,15 @@ export class MyAccountVideoPlaylistUpdateComponent extends MyAccountVideoPlaylis
 
   ngOnInit () {
     this.buildForm({
-      displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME,
-      privacy: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_PRIVACY,
-      description: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DESCRIPTION,
-      videoChannelId: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_CHANNEL_ID,
+      displayName: VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
+      privacy: VIDEO_PLAYLIST_PRIVACY_VALIDATOR,
+      description: VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
+      videoChannelId: VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
       thumbnailfile: null
     })
 
     this.form.get('privacy').valueChanges.subscribe(privacy => {
-      this.videoPlaylistValidatorsService.setChannelValidator(this.form.get('videoChannelId'), privacy)
+      setPlaylistChannelValidator(this.form.get('videoChannelId'), privacy)
     })
 
     populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
index edd6916940f9d83c7e7fc5484e442f704980b282..84237dee1761a14d740cb3fd4f4bd88531635736 100644 (file)
@@ -1,6 +1,7 @@
 import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
 import { Notifier, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, VideoChangeOwnershipValidatorsService } from '@app/shared/shared-forms'
+import { OWNERSHIP_CHANGE_USERNAME_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { Video, VideoOwnershipService } from '@app/shared/shared-main'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 
@@ -20,7 +21,6 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private videoChangeOwnershipValidatorsService: VideoChangeOwnershipValidatorsService,
     private videoOwnershipService: VideoOwnershipService,
     private notifier: Notifier,
     private userService: UserService,
@@ -31,7 +31,7 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni
 
   ngOnInit () {
     this.buildForm({
-      username: this.videoChangeOwnershipValidatorsService.USERNAME
+      username: OWNERSHIP_CHANGE_USERNAME_VALIDATOR
     })
     this.usernamePropositions = []
   }
index 16e4f4090c84c62e3170f051d4a13cadbfd47680..ce9144170b7ba64d34b83447c0c35358dfe02452 100644 (file)
@@ -1,7 +1,9 @@
 import { Component, OnInit } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
 import { Notifier, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, ResetPasswordValidatorsService, UserValidatorsService } from '@app/shared/shared-forms'
+import { RESET_PASSWORD_CONFIRM_VALIDATOR } from '@app/shared/form-validators/reset-password-validators'
+import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 
 @Component({
   selector: 'my-login',
@@ -15,8 +17,6 @@ export class ResetPasswordComponent extends FormReactive implements OnInit {
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private resetPasswordValidatorsService: ResetPasswordValidatorsService,
-    private userValidatorsService: UserValidatorsService,
     private userService: UserService,
     private notifier: Notifier,
     private router: Router,
@@ -27,8 +27,8 @@ export class ResetPasswordComponent extends FormReactive implements OnInit {
 
   ngOnInit () {
     this.buildForm({
-      password: this.userValidatorsService.USER_PASSWORD,
-      'password-confirm': this.resetPasswordValidatorsService.RESET_PASSWORD_CONFIRM
+      password: USER_PASSWORD_VALIDATOR,
+      'password-confirm': RESET_PASSWORD_CONFIRM_VALIDATOR
     })
 
     this.userId = this.route.snapshot.queryParams['userId']
index 8a01208405c87333a04c2d35d7f119853cdd9345..d965a786550697e5a4bd54f53b2ecda715805fe9 100644 (file)
@@ -3,7 +3,8 @@ import { pairwise } from 'rxjs/operators'
 import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
 import { FormGroup } from '@angular/forms'
 import { UserService } from '@app/core'
-import { FormReactive, FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms'
+import { VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, VIDEO_CHANNEL_NAME_VALIDATOR } from '@app/shared/form-validators/video-channel-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 
 @Component({
   selector: 'my-register-step-channel',
@@ -16,8 +17,7 @@ export class RegisterStepChannelComponent extends FormReactive implements OnInit
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private userService: UserService,
-    private videoChannelValidatorsService: VideoChannelValidatorsService
+    private userService: UserService
   ) {
     super()
   }
@@ -28,8 +28,8 @@ export class RegisterStepChannelComponent extends FormReactive implements OnInit
 
   ngOnInit () {
     this.buildForm({
-      displayName: this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME,
-      name: this.videoChannelValidatorsService.VIDEO_CHANNEL_NAME
+      displayName: VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
+      name: VIDEO_CHANNEL_NAME_VALIDATOR
     })
 
     setTimeout(() => this.formBuilt.emit(this.form))
index 3d9ab8b6b13646dc3b87f92664086b60f1a74a35..65536568bcbc9c7b6fd81f95a9ffc16b362653be 100644 (file)
@@ -3,7 +3,14 @@ import { pairwise } from 'rxjs/operators'
 import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
 import { FormGroup } from '@angular/forms'
 import { UserService } from '@app/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import {
+  USER_DISPLAY_NAME_REQUIRED_VALIDATOR,
+  USER_EMAIL_VALIDATOR,
+  USER_PASSWORD_VALIDATOR,
+  USER_TERMS_VALIDATOR,
+  USER_USERNAME_VALIDATOR
+} from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 
 @Component({
   selector: 'my-register-step-user',
@@ -19,8 +26,7 @@ export class RegisterStepUserComponent extends FormReactive implements OnInit {
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private userService: UserService,
-    private userValidatorsService: UserValidatorsService
+    private userService: UserService
   ) {
     super()
   }
@@ -31,11 +37,11 @@ export class RegisterStepUserComponent extends FormReactive implements OnInit {
 
   ngOnInit () {
     this.buildForm({
-      displayName: this.userValidatorsService.USER_DISPLAY_NAME_REQUIRED,
-      username: this.userValidatorsService.USER_USERNAME,
-      password: this.userValidatorsService.USER_PASSWORD,
-      email: this.userValidatorsService.USER_EMAIL,
-      terms: this.userValidatorsService.USER_TERMS
+      displayName: USER_DISPLAY_NAME_REQUIRED_VALIDATOR,
+      username: USER_USERNAME_VALIDATOR,
+      password: USER_PASSWORD_VALIDATOR,
+      email: USER_EMAIL_VALIDATOR,
+      terms: USER_TERMS_VALIDATOR
     })
 
     setTimeout(() => this.formBuilt.emit(this.form))
index b26581d2bae5cb59ec23e00df5e726a604e850ae..830dd996234f45bc3b16fa2760e41a1a88d0f834 100644 (file)
@@ -1,6 +1,7 @@
 import { Component, OnInit } from '@angular/core'
 import { Notifier, RedirectService, ServerService, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import { USER_EMAIL_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { ServerConfig } from '@shared/models'
 
 @Component({
@@ -14,7 +15,6 @@ export class VerifyAccountAskSendEmailComponent extends FormReactive implements
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private userValidatorsService: UserValidatorsService,
     private userService: UserService,
     private serverService: ServerService,
     private notifier: Notifier,
@@ -33,7 +33,7 @@ export class VerifyAccountAskSendEmailComponent extends FormReactive implements
         .subscribe(config => this.serverConfig = config)
 
     this.buildForm({
-      'verify-email-email': this.userValidatorsService.USER_EMAIL
+      'verify-email-email': USER_EMAIL_VALIDATOR
     })
   }
 
index a90d04ce82fe39ee92165cb4283c838b554aac73..e48d16527bebf37a85c0e1ec4b1c42de2e05f347 100644 (file)
@@ -1,6 +1,7 @@
 import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
 import { ServerService } from '@app/core'
-import { FormReactive, FormValidatorService, VideoCaptionsValidatorsService } from '@app/shared/shared-forms'
+import { VIDEO_CAPTION_FILE_VALIDATOR, VIDEO_CAPTION_LANGUAGE_VALIDATOR } from '@app/shared/form-validators/video-captions-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { VideoCaptionEdit } from '@app/shared/shared-main'
 import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
 import { ServerConfig, VideoConstant } from '@shared/models'
@@ -27,8 +28,7 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni
   constructor (
     protected formValidatorService: FormValidatorService,
     private modalService: NgbModal,
-    private serverService: ServerService,
-    private videoCaptionsValidatorsService: VideoCaptionsValidatorsService
+    private serverService: ServerService
   ) {
     super()
   }
@@ -46,8 +46,8 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni
         .subscribe(languages => this.videoCaptionLanguages = languages)
 
     this.buildForm({
-      language: this.videoCaptionsValidatorsService.VIDEO_CAPTION_LANGUAGE,
-      captionfile: this.videoCaptionsValidatorsService.VIDEO_CAPTION_FILE
+      language: VIDEO_CAPTION_LANGUAGE_VALIDATOR,
+      captionfile: VIDEO_CAPTION_FILE_VALIDATOR
     })
   }
 
index 050b6d931b38f7ed90338ae11b7ff562960563b8..92d06aa12414c58f44948a0e03d2cd3d9bb70c27 100644 (file)
@@ -4,7 +4,20 @@ import { Component, Input, NgZone, OnDestroy, OnInit, ViewChild } from '@angular
 import { FormArray, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms'
 import { ServerService } from '@app/core'
 import { removeElementFromArray } from '@app/helpers'
-import { FormReactiveValidationMessages, FormValidatorService, SelectChannelItem, VideoValidatorsService } from '@app/shared/shared-forms'
+import {
+  VIDEO_CATEGORY_VALIDATOR,
+  VIDEO_CHANNEL_VALIDATOR,
+  VIDEO_DESCRIPTION_VALIDATOR,
+  VIDEO_LANGUAGE_VALIDATOR,
+  VIDEO_LICENCE_VALIDATOR,
+  VIDEO_NAME_VALIDATOR,
+  VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR,
+  VIDEO_PRIVACY_VALIDATOR,
+  VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR,
+  VIDEO_SUPPORT_VALIDATOR,
+  VIDEO_TAGS_ARRAY_VALIDATOR
+} from '@app/shared/form-validators/video-validators'
+import { FormReactiveValidationMessages, FormValidatorService, SelectChannelItem } from '@app/shared/shared-forms'
 import { InstanceService } from '@app/shared/shared-instance'
 import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main'
 import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models'
@@ -57,7 +70,6 @@ export class VideoEditComponent implements OnInit, OnDestroy {
 
   constructor (
     private formValidatorService: FormValidatorService,
-    private videoValidatorsService: VideoValidatorsService,
     private videoService: VideoService,
     private serverService: ServerService,
     private instanceService: InstanceService,
@@ -84,22 +96,22 @@ export class VideoEditComponent implements OnInit, OnDestroy {
       tags: []
     }
     const obj: any = {
-      name: this.videoValidatorsService.VIDEO_NAME,
-      privacy: this.videoValidatorsService.VIDEO_PRIVACY,
-      channelId: this.videoValidatorsService.VIDEO_CHANNEL,
+      name: VIDEO_NAME_VALIDATOR,
+      privacy: VIDEO_PRIVACY_VALIDATOR,
+      channelId: VIDEO_CHANNEL_VALIDATOR,
       nsfw: null,
       commentsEnabled: null,
       downloadEnabled: null,
       waitTranscoding: null,
-      category: this.videoValidatorsService.VIDEO_CATEGORY,
-      licence: this.videoValidatorsService.VIDEO_LICENCE,
-      language: this.videoValidatorsService.VIDEO_LANGUAGE,
-      description: this.videoValidatorsService.VIDEO_DESCRIPTION,
-      tags: this.videoValidatorsService.VIDEO_TAGS_ARRAY,
+      category: VIDEO_CATEGORY_VALIDATOR,
+      licence: VIDEO_LICENCE_VALIDATOR,
+      language: VIDEO_LANGUAGE_VALIDATOR,
+      description: VIDEO_DESCRIPTION_VALIDATOR,
+      tags: VIDEO_TAGS_ARRAY_VALIDATOR,
       previewfile: null,
-      support: this.videoValidatorsService.VIDEO_SUPPORT,
-      schedulePublicationAt: this.videoValidatorsService.VIDEO_SCHEDULE_PUBLICATION_AT,
-      originallyPublishedAt: this.videoValidatorsService.VIDEO_ORIGINALLY_PUBLISHED_AT
+      support: VIDEO_SUPPORT_VALIDATOR,
+      schedulePublicationAt: VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR,
+      originallyPublishedAt: VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR
     }
 
     this.formValidatorService.updateForm(
index fa20ec3b9db8a3df388ded3ebefeb50a40a0b0d1..c1d0032cc023193b7437d180d0685fc699fe4419 100644 (file)
@@ -2,7 +2,8 @@ import { Observable } from 'rxjs'
 import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core'
 import { Router } from '@angular/router'
 import { Notifier, User } from '@app/core'
-import { FormReactive, FormValidatorService, VideoCommentValidatorsService } from '@app/shared/shared-forms'
+import { VIDEO_COMMENT_TEXT_VALIDATOR } from '@app/shared/form-validators/video-comment-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { Video } from '@app/shared/shared-main'
 import { VideoComment, VideoCommentService } from '@app/shared/shared-video-comment'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
@@ -33,7 +34,6 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private videoCommentValidatorsService: VideoCommentValidatorsService,
     private notifier: Notifier,
     private videoCommentService: VideoCommentService,
     private modalService: NgbModal,
@@ -50,7 +50,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
 
   ngOnInit () {
     this.buildForm({
-      text: this.videoCommentValidatorsService.VIDEO_COMMENT_TEXT
+      text: VIDEO_COMMENT_TEXT_VALIDATOR
     })
 
     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 (file)
index 0000000..75bfacf
--- /dev/null
@@ -0,0 +1,29 @@
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const ABUSE_REASON_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.required, Validators.minLength(2), Validators.maxLength(3000)],
+  MESSAGES: {
+    'required': $localize`Report reason is required.`,
+    'minlength': $localize`Report reason must be at least 2 characters long.`,
+    'maxlength': $localize`Report reason cannot be more than 3000 characters long.`
+  }
+}
+
+export const ABUSE_MODERATION_COMMENT_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.required, Validators.minLength(2), Validators.maxLength(3000)],
+  MESSAGES: {
+    'required': $localize`Moderation comment is required.`,
+    'minlength': $localize`Moderation comment must be at least 2 characters long.`,
+    'maxlength': $localize`Moderation comment cannot be more than 3000 characters long.`
+  }
+}
+
+export const ABUSE_MESSAGE_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.required, Validators.minLength(2), Validators.maxLength(3000)],
+  MESSAGES: {
+    'required': $localize`Abuse message is required.`,
+    'minlength': $localize`Abuse message must be at least 2 characters long.`,
+    'maxlength': $localize`Abuse message cannot be more than 3000 characters long.`
+  }
+}
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 (file)
index 0000000..423d133
--- /dev/null
@@ -0,0 +1,60 @@
+import { AbstractControl, FormControl, ValidatorFn, Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+import { validateHost } from './host'
+
+export function getNotEmptyHosts (hosts: string) {
+  return hosts
+    .split('\n')
+    .filter((host: string) => host && host.length !== 0) // Eject empty hosts
+}
+
+const validDomains: ValidatorFn = (control: FormControl) => {
+  if (!control.value) return null
+
+  const newHostsErrors = []
+  const hosts = getNotEmptyHosts(control.value)
+
+  for (const host of hosts) {
+    if (validateHost(host) === false) {
+      newHostsErrors.push($localize`${host} is not valid`)
+    }
+  }
+
+  /* Is not valid. */
+  if (newHostsErrors.length !== 0) {
+    return {
+      'validDomains': {
+        reason: 'invalid',
+        value: newHostsErrors.join('. ') + '.'
+      }
+    }
+  }
+
+  /* Is valid. */
+  return null
+}
+
+const isHostsUnique: ValidatorFn = (control: AbstractControl) => {
+  if (!control.value) return null
+
+  const hosts = getNotEmptyHosts(control.value)
+
+  if (hosts.every((host: string) => hosts.indexOf(host) === hosts.lastIndexOf(host))) {
+    return null
+  } else {
+    return {
+      'uniqueDomains': {
+        reason: 'invalid'
+      }
+    }
+  }
+}
+
+export const DOMAINS_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.required, validDomains, isHostsUnique],
+  MESSAGES: {
+    'required': $localize`Domain is required.`,
+    'validDomains': $localize`Domains entered are invalid.`,
+    'uniqueDomains': $localize`Domains entered contain duplicates.`
+  }
+}
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 (file)
index 0000000..41b3cbb
--- /dev/null
@@ -0,0 +1,80 @@
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const INSTANCE_NAME_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.required],
+  MESSAGES: {
+    'required': $localize`Instance name is required.`
+  }
+}
+
+export const INSTANCE_SHORT_DESCRIPTION_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.max(250)],
+  MESSAGES: {
+    'max': $localize`Short description should not be longer than 250 characters.`
+  }
+}
+
+export const SERVICES_TWITTER_USERNAME_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.required],
+  MESSAGES: {
+    'required': $localize`Twitter username is required.`
+  }
+}
+
+export const CACHE_PREVIEWS_SIZE_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.required, Validators.min(1), Validators.pattern('[0-9]+')],
+  MESSAGES: {
+    'required': $localize`Previews cache size is required.`,
+    'min': $localize`Previews cache size must be greater than 1.`,
+    'pattern': $localize`Previews cache size must be a number.`
+  }
+}
+
+export const CACHE_CAPTIONS_SIZE_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.required, Validators.min(1), Validators.pattern('[0-9]+')],
+  MESSAGES: {
+    'required': $localize`Captions cache size is required.`,
+    'min': $localize`Captions cache size must be greater than 1.`,
+    'pattern': $localize`Captions cache size must be a number.`
+  }
+}
+
+export const SIGNUP_LIMIT_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.required, Validators.min(-1), Validators.pattern('-?[0-9]+')],
+  MESSAGES: {
+    'required': $localize`Signup limit is required.`,
+    'min': $localize`Signup limit must be greater than 1.`,
+    'pattern': $localize`Signup limit must be a number.`
+  }
+}
+
+export const ADMIN_EMAIL_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.required, Validators.email],
+  MESSAGES: {
+    'required': $localize`Admin email is required.`,
+    'email': $localize`Admin email must be valid.`
+  }
+}
+
+export const TRANSCODING_THREADS_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.required, Validators.min(0)],
+  MESSAGES: {
+    'required': $localize`Transcoding threads is required.`,
+    'min': $localize`Transcoding threads must be greater or equal to 0.`
+  }
+}
+
+export const INDEX_URL_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.pattern(/^https:\/\//)],
+  MESSAGES: {
+    'pattern': $localize`Index URL should be a URL`
+  }
+}
+
+export const SEARCH_INDEX_URL_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.pattern(/^https?:\/\//)],
+  MESSAGES: {
+    'pattern': $localize`Search index URL should be a URL`
+  }
+}
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 (file)
index 0000000..248a3b1
--- /dev/null
@@ -0,0 +1,14 @@
+import { ValidatorFn } from '@angular/forms'
+
+export type BuildFormValidator = {
+  VALIDATORS: ValidatorFn[],
+  MESSAGES: { [ name: string ]: string }
+}
+
+export type BuildFormArgument = {
+  [ id: string ]: BuildFormValidator | BuildFormArgument
+}
+
+export type BuildFormDefaultValues = {
+  [ name: string ]: string | string[] | BuildFormDefaultValues
+}
diff --git a/client/src/app/shared/form-validators/index.ts b/client/src/app/shared/form-validators/index.ts
new file mode 100644 (file)
index 0000000..f621f03
--- /dev/null
@@ -0,0 +1,17 @@
+export * from './form-validator.model'
+export * from './host'
+
+// Don't re export const variables because webpack 4 cannot do tree shaking with them
+// export * from './abuse-validators'
+// export * from './batch-domains-validators'
+// export * from './custom-config-validators'
+// export * from './instance-validators'
+// export * from './login-validators'
+// export * from './reset-password-validators'
+// export * from './user-validators'
+// export * from './video-block-validators'
+// export * from './video-captions-validators'
+// export * from './video-channel-validators'
+// export * from './video-comment-validators'
+// export * from './video-playlist-validators'
+// 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 (file)
index 0000000..a72e28b
--- /dev/null
@@ -0,0 +1,49 @@
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const FROM_EMAIL_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [Validators.required, Validators.email],
+  MESSAGES: {
+    'required': $localize`Email is required.`,
+    'email': $localize`Email must be valid.`
+  }
+}
+
+export const FROM_NAME_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.required,
+    Validators.minLength(1),
+    Validators.maxLength(120)
+  ],
+  MESSAGES: {
+    'required': $localize`Your name is required.`,
+    'minlength': $localize`Your name must be at least 1 character long.`,
+    'maxlength': $localize`Your name cannot be more than 120 characters long.`
+  }
+}
+
+export const SUBJECT_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.required,
+    Validators.minLength(1),
+    Validators.maxLength(120)
+  ],
+  MESSAGES: {
+    'required': $localize`A subject is required.`,
+    'minlength': $localize`The subject must be at least 1 character long.`,
+    'maxlength': $localize`The subject cannot be more than 120 characters long.`
+  }
+}
+
+export const BODY_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.required,
+    Validators.minLength(3),
+    Validators.maxLength(5000)
+  ],
+  MESSAGES: {
+    'required': $localize`A message is required.`,
+    'minlength': $localize`The message must be at least 3 characters long.`,
+    'maxlength': $localize`The message cannot be more than 5000 characters long.`
+  }
+}
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 (file)
index 0000000..1ceae1b
--- /dev/null
@@ -0,0 +1,20 @@
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const LOGIN_USERNAME_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.required
+  ],
+  MESSAGES: {
+    'required': $localize`Username is required.`
+  }
+}
+
+export const LOGIN_PASSWORD_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.required
+  ],
+  MESSAGES: {
+    'required': $localize`Password is required.`
+  }
+}
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 (file)
index 0000000..b87f2ea
--- /dev/null
@@ -0,0 +1,11 @@
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const RESET_PASSWORD_CONFIRM_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.required
+  ],
+  MESSAGES: {
+    'required': $localize`Confirmation of the password is required.`
+  }
+}
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 (file)
index 0000000..1819950
--- /dev/null
@@ -0,0 +1,144 @@
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const USER_USERNAME_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.required,
+    Validators.minLength(1),
+    Validators.maxLength(50),
+    Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
+  ],
+  MESSAGES: {
+    'required': $localize`Username is required.`,
+    'minlength': $localize`Username must be at least 1 character long.`,
+    'maxlength': $localize`Username cannot be more than 50 characters long.`,
+    'pattern': $localize`Username should be lowercase alphanumeric; dots and underscores are allowed.`
+  }
+}
+
+export const USER_CHANNEL_NAME_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.required,
+    Validators.minLength(1),
+    Validators.maxLength(50),
+    Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
+  ],
+  MESSAGES: {
+    'required': $localize`Channel name is required.`,
+    'minlength': $localize`Channel name must be at least 1 character long.`,
+    'maxlength': $localize`Channel name cannot be more than 50 characters long.`,
+    'pattern': $localize`Channel name should be lowercase alphanumeric; dots and underscores are allowed.`
+  }
+}
+
+export const USER_EMAIL_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.required, Validators.email ],
+  MESSAGES: {
+    'required': $localize`Email is required.`,
+    'email': $localize`Email must be valid.`
+  }
+}
+
+export const USER_PASSWORD_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.required,
+    Validators.minLength(6),
+    Validators.maxLength(255)
+  ],
+  MESSAGES: {
+    'required': $localize`Password is required.`,
+    'minlength': $localize`Password must be at least 6 characters long.`,
+    'maxlength': $localize`Password cannot be more than 255 characters long.`
+  }
+}
+
+export const USER_PASSWORD_OPTIONAL_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.minLength(6),
+    Validators.maxLength(255)
+  ],
+  MESSAGES: {
+    'minlength': $localize`Password must be at least 6 characters long.`,
+    'maxlength': $localize`Password cannot be more than 255 characters long.`
+  }
+}
+
+export const USER_CONFIRM_PASSWORD_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [],
+  MESSAGES: {
+    'matchPassword': $localize`The new password and the confirmed password do not correspond.`
+  }
+}
+
+export const USER_VIDEO_QUOTA_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.required, Validators.min(-1) ],
+  MESSAGES: {
+    'required': $localize`Video quota is required.`,
+    'min': $localize`Quota must be greater than -1.`
+  }
+}
+export const USER_VIDEO_QUOTA_DAILY_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.required, Validators.min(-1) ],
+  MESSAGES: {
+    'required': $localize`Daily upload limit is required.`,
+    'min': $localize`Daily upload limit must be greater than -1.`
+  }
+}
+
+export const USER_ROLE_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.required ],
+  MESSAGES: {
+    'required': $localize`User role is required.`
+  }
+}
+
+export const USER_DISPLAY_NAME_REQUIRED_VALIDATOR = buildDisplayNameValidator(true)
+
+export const USER_DESCRIPTION_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.minLength(3),
+    Validators.maxLength(1000)
+  ],
+  MESSAGES: {
+    'minlength': $localize`Description must be at least 3 characters long.`,
+    'maxlength': $localize`Description cannot be more than 1000 characters long.`
+  }
+}
+
+export const USER_TERMS_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.requiredTrue
+  ],
+  MESSAGES: {
+    'required': $localize`You must agree with the instance terms in order to register on it.`
+  }
+}
+
+export const USER_BAN_REASON_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.minLength(3),
+    Validators.maxLength(250)
+  ],
+  MESSAGES: {
+    'minlength': $localize`Ban reason must be at least 3 characters long.`,
+    'maxlength': $localize`Ban reason cannot be more than 250 characters long.`
+  }
+}
+
+function buildDisplayNameValidator (required: boolean) {
+  const control = {
+    VALIDATORS: [
+      Validators.minLength(1),
+      Validators.maxLength(120)
+    ],
+    MESSAGES: {
+      'required': $localize`Display name is required.`,
+      'minlength': $localize`Display name must be at least 1 character long.`,
+      'maxlength': $localize`Display name cannot be more than 50 characters long.`
+    }
+  }
+
+  if (required) control.VALIDATORS.push(Validators.required)
+
+  return control
+}
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 (file)
index 0000000..d3974ae
--- /dev/null
@@ -0,0 +1,10 @@
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const VIDEO_BLOCK_REASON_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.minLength(2), Validators.maxLength(300) ],
+  MESSAGES: {
+    'minlength': $localize`Block reason must be at least 2 characters long.`,
+    'maxlength': $localize`Block reason cannot be more than 300 characters long.`
+  }
+}
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 (file)
index 0000000..9742d29
--- /dev/null
@@ -0,0 +1,16 @@
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const VIDEO_CAPTION_LANGUAGE_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.required ],
+  MESSAGES: {
+    'required': $localize`Video caption language is required.`
+  }
+}
+
+export const VIDEO_CAPTION_FILE_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.required ],
+  MESSAGES: {
+    'required': $localize`Video caption file is required.`
+  }
+}
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 (file)
index 0000000..0daab22
--- /dev/null
@@ -0,0 +1,52 @@
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const VIDEO_CHANNEL_NAME_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.required,
+    Validators.minLength(1),
+    Validators.maxLength(50),
+    Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
+  ],
+  MESSAGES: {
+    'required': $localize`Name is required.`,
+    'minlength': $localize`Name must be at least 1 character long.`,
+    'maxlength': $localize`Name cannot be more than 50 characters long.`,
+    'pattern': $localize`Name should be lowercase alphanumeric; dots and underscores are allowed.`
+  }
+}
+
+export const VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.required,
+    Validators.minLength(1),
+    Validators.maxLength(50)
+  ],
+  MESSAGES: {
+    'required': $localize`Display name is required.`,
+    'minlength': $localize`Display name must be at least 1 character long.`,
+    'maxlength': $localize`Display name cannot be more than 50 characters long.`
+  }
+}
+
+export const VIDEO_CHANNEL_DESCRIPTION_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.minLength(3),
+    Validators.maxLength(1000)
+  ],
+  MESSAGES: {
+    'minlength': $localize`Description must be at least 3 characters long.`,
+    'maxlength': $localize`Description cannot be more than 1000 characters long.`
+  }
+}
+
+export const VIDEO_CHANNEL_SUPPORT_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.minLength(3),
+    Validators.maxLength(1000)
+  ],
+  MESSAGES: {
+    'minlength': $localize`Support text must be at least 3 characters long.`,
+    'maxlength': $localize`Support text cannot be more than 1000 characters long`
+  }
+}
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 (file)
index 0000000..c56564d
--- /dev/null
@@ -0,0 +1,11 @@
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const VIDEO_COMMENT_TEXT_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.required, Validators.minLength(1), Validators.maxLength(3000) ],
+  MESSAGES: {
+    'required': $localize`Comment is required.`,
+    'minlength': $localize`Comment must be at least 2 characters long.`,
+    'maxlength': $localize`Comment cannot be more than 3000 characters long.`
+  }
+}
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 (file)
index 0000000..e1a2df8
--- /dev/null
@@ -0,0 +1,25 @@
+import { AbstractControl, ValidationErrors, Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const OWNERSHIP_CHANGE_CHANNEL_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.required ],
+  MESSAGES: {
+    'required': $localize`The channel is required.`
+  }
+}
+
+export const OWNERSHIP_CHANGE_USERNAME_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.required, localAccountValidator ],
+  MESSAGES: {
+    'required': $localize`The username is required.`,
+    'localAccountOnly': $localize`You can only transfer ownership to a local account`
+  }
+}
+
+function localAccountValidator (control: AbstractControl): ValidationErrors {
+  if (control.value.includes('@')) {
+    return { 'localAccountOnly': true }
+  }
+
+  return null
+}
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 (file)
index 0000000..7e3d294
--- /dev/null
@@ -0,0 +1,54 @@
+import { Validators, AbstractControl } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+import { VideoPlaylistPrivacy } from '@shared/models'
+
+export const VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.required,
+    Validators.minLength(1),
+    Validators.maxLength(120)
+  ],
+  MESSAGES: {
+    'required': $localize`Display name is required.`,
+    'minlength': $localize`Display name must be at least 1 character long.`,
+    'maxlength': $localize`Display name cannot be more than 120 characters long.`
+  }
+}
+
+export const VIDEO_PLAYLIST_PRIVACY_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.required
+  ],
+  MESSAGES: {
+    'required': $localize`Privacy is required.`
+  }
+}
+
+export const VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.minLength(3),
+    Validators.maxLength(1000)
+  ],
+  MESSAGES: {
+    'minlength': $localize`Description must be at least 3 characters long.`,
+    'maxlength': $localize`Description cannot be more than 1000 characters long.`
+  }
+}
+
+export const VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [],
+  MESSAGES: {
+    'required': $localize`The channel is required when the playlist is public.`
+  }
+}
+
+export function setPlaylistChannelValidator (channelControl: AbstractControl, privacy: VideoPlaylistPrivacy) {
+  if (privacy.toString() === VideoPlaylistPrivacy.PUBLIC.toString()) {
+    channelControl.setValidators([Validators.required])
+  } else {
+    channelControl.setValidators(null)
+  }
+
+  channelControl.markAsDirty()
+  channelControl.updateValueAndValidity()
+}
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 (file)
index 0000000..23f2391
--- /dev/null
@@ -0,0 +1,101 @@
+import { AbstractControl, ValidationErrors, ValidatorFn, Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const VIDEO_NAME_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ],
+  MESSAGES: {
+    'required': $localize`Video name is required.`,
+    'minlength': $localize`Video name must be at least 3 characters long.`,
+    'maxlength': $localize`Video name cannot be more than 120 characters long.`
+  }
+}
+
+export const VIDEO_PRIVACY_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.required ],
+  MESSAGES: {
+    'required': $localize`Video privacy is required.`
+  }
+}
+
+export const VIDEO_CATEGORY_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ ],
+  MESSAGES: {}
+}
+
+export const VIDEO_LICENCE_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ ],
+  MESSAGES: {}
+}
+
+export const VIDEO_LANGUAGE_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ ],
+  MESSAGES: {}
+}
+
+export const VIDEO_IMAGE_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ ],
+  MESSAGES: {}
+}
+
+export const VIDEO_CHANNEL_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.required ],
+  MESSAGES: {
+    'required': $localize`Video channel is required.`
+  }
+}
+
+export const VIDEO_DESCRIPTION_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ],
+  MESSAGES: {
+    'minlength': $localize`Video description must be at least 3 characters long.`,
+    'maxlength': $localize`Video description cannot be more than 10000 characters long.`
+  }
+}
+
+export const VIDEO_TAG_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ],
+  MESSAGES: {
+    'minlength': $localize`A tag should be more than 2 characters long.`,
+    'maxlength': $localize`A tag should be less than 30 characters long.`
+  }
+}
+
+export const VIDEO_TAGS_ARRAY_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.maxLength(5), arrayTagLengthValidator() ],
+  MESSAGES: {
+    'maxlength': $localize`A maximum of 5 tags can be used on a video.`,
+    'arrayTagLength': $localize`A tag should be more than 2, and less than 30 characters long.`
+  }
+}
+
+export const VIDEO_SUPPORT_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.minLength(3), Validators.maxLength(1000) ],
+  MESSAGES: {
+    'minlength': $localize`Video support must be at least 3 characters long.`,
+    'maxlength': $localize`Video support cannot be more than 1000 characters long.`
+  }
+}
+
+export const VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ ],
+  MESSAGES: {
+    'required': $localize`A date is required to schedule video update.`
+  }
+}
+
+export const VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ ],
+  MESSAGES: {}
+}
+
+function arrayTagLengthValidator (min = 2, max = 30): ValidatorFn {
+  return (control: AbstractControl): ValidationErrors => {
+    const array = control.value as Array<string>
+
+    if (array.every(e => e.length > min && e.length < max)) {
+      return null
+    }
+
+    return { 'arrayTagLength': true }
+  }
+}
index 0c3c8ff48a7218d5930a719b3853a7c112895a3f..9abb4c094e21fe93151dc3cf976bf6895964d374 100644 (file)
@@ -1,9 +1,10 @@
 import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
 import { AuthService, HtmlRendererService, Notifier } from '@app/core'
-import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
 import { AbuseMessage, UserAbuse } from '@shared/models'
+import { ABUSE_MESSAGE_VALIDATOR } from '../form-validators/abuse-validators'
 import { AbuseService } from '../shared-moderation'
 
 @Component({
@@ -28,7 +29,6 @@ export class AbuseMessageModalComponent extends FormReactive implements OnInit {
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private abuseValidatorsService: AbuseValidatorsService,
     private modalService: NgbModal,
     private htmlRenderer: HtmlRendererService,
     private auth: AuthService,
@@ -40,7 +40,7 @@ export class AbuseMessageModalComponent extends FormReactive implements OnInit {
 
   ngOnInit () {
     this.buildForm({
-      message: this.abuseValidatorsService.ABUSE_MESSAGE
+      message: ABUSE_MESSAGE_VALIDATOR
     })
   }
 
index fad7f888da5c71788c3182745c7e4894dd2104f6..876aeea8a7eecb75471d97e4946733ef53aaa6ba 100644 (file)
@@ -1,10 +1,11 @@
 import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
 import { Notifier } from '@app/core'
-import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { AbuseService } from '@app/shared/shared-moderation'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
 import { AdminAbuse } from '@shared/models'
+import { ABUSE_MODERATION_COMMENT_VALIDATOR } from '../form-validators/abuse-validators'
 
 @Component({
   selector: 'my-moderation-comment-modal',
@@ -22,15 +23,14 @@ export class ModerationCommentModalComponent extends FormReactive implements OnI
     protected formValidatorService: FormValidatorService,
     private modalService: NgbModal,
     private notifier: Notifier,
-    private abuseService: AbuseService,
-    private abuseValidatorsService: AbuseValidatorsService
+    private abuseService: AbuseService
   ) {
     super()
   }
 
   ngOnInit () {
     this.buildForm({
-      moderationComment: this.abuseValidatorsService.ABUSE_MODERATION_COMMENT
+      moderationComment: ABUSE_MODERATION_COMMENT_VALIDATOR
     })
   }
 
index caa31d831326195ecef72e2167af919c5e8e0215..adf6cb8941dff297f0ff394f9e255d495bf51349 100644 (file)
@@ -1,5 +1,6 @@
 import { FormGroup } from '@angular/forms'
-import { BuildFormArgument, BuildFormDefaultValues, FormValidatorService } from './form-validators'
+import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model'
+import { FormValidatorService } from './form-validator.service'
 
 export type FormReactiveErrors = { [ id: string ]: string | FormReactiveErrors }
 export type FormReactiveValidationMessages = {
similarity index 88%
rename from client/src/app/shared/shared-forms/form-validators/form-validator.service.ts
rename to client/src/app/shared/shared-forms/form-validator.service.ts
index dec7d8d9a06fa8d2a425e5e3e9d5578edebcf040..41c8b76bde96e16b93bab17e4e8b76b6eb5b3f97 100644 (file)
@@ -1,17 +1,7 @@
-import { FormBuilder, FormControl, FormGroup, ValidatorFn } from '@angular/forms'
 import { Injectable } from '@angular/core'
-import { FormReactiveErrors, FormReactiveValidationMessages } from '../form-reactive'
-
-export type BuildFormValidator = {
-  VALIDATORS: ValidatorFn[],
-  MESSAGES: { [ name: string ]: string }
-}
-export type BuildFormArgument = {
-  [ id: string ]: BuildFormValidator | BuildFormArgument
-}
-export type BuildFormDefaultValues = {
-  [ name: string ]: string | string[] | BuildFormDefaultValues
-}
+import { FormBuilder, FormControl, FormGroup, ValidatorFn } from '@angular/forms'
+import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model'
+import { FormReactiveErrors, FormReactiveValidationMessages } from './form-reactive'
 
 @Injectable()
 export 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 (file)
index 56d30d6..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class AbuseValidatorsService {
-  readonly ABUSE_REASON: BuildFormValidator
-  readonly ABUSE_MODERATION_COMMENT: BuildFormValidator
-  readonly ABUSE_MESSAGE: BuildFormValidator
-
-  constructor () {
-    this.ABUSE_REASON = {
-      VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
-      MESSAGES: {
-        'required': $localize`Report reason is required.`,
-        'minlength': $localize`Report reason must be at least 2 characters long.`,
-        'maxlength': $localize`Report reason cannot be more than 3000 characters long.`
-      }
-    }
-
-    this.ABUSE_MODERATION_COMMENT = {
-      VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
-      MESSAGES: {
-        'required': $localize`Moderation comment is required.`,
-        'minlength': $localize`Moderation comment must be at least 2 characters long.`,
-        'maxlength': $localize`Moderation comment cannot be more than 3000 characters long.`
-      }
-    }
-
-    this.ABUSE_MESSAGE = {
-      VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
-      MESSAGES: {
-        'required': $localize`Abuse message is required.`,
-        'minlength': $localize`Abuse message must be at least 2 characters long.`,
-        'maxlength': $localize`Abuse message cannot be more than 3000 characters long.`
-      }
-    }
-  }
-}
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 (file)
index 6c7da83..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-import { Injectable } from '@angular/core'
-import { ValidatorFn, Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-import { validateHost } from './host'
-
-@Injectable()
-export class BatchDomainsValidatorsService {
-  readonly DOMAINS: BuildFormValidator
-
-  constructor () {
-    this.DOMAINS = {
-      VALIDATORS: [ Validators.required, this.validDomains, this.isHostsUnique ],
-      MESSAGES: {
-        'required': $localize`Domain is required.`,
-        'validDomains': $localize`Domains entered are invalid.`,
-        'uniqueDomains': $localize`Domains entered contain duplicates.`
-      }
-    }
-  }
-
-  getNotEmptyHosts (hosts: string) {
-    return hosts
-      .split('\n')
-      .filter((host: string) => host && host.length !== 0) // Eject empty hosts
-  }
-
-  private validDomains: ValidatorFn = (control) => {
-    if (!control.value) return null
-
-    const newHostsErrors = []
-    const hosts = this.getNotEmptyHosts(control.value)
-
-    for (const host of hosts) {
-      if (validateHost(host) === false) {
-        newHostsErrors.push($localize`${host} is not valid`)
-      }
-    }
-
-    /* Is not valid. */
-    if (newHostsErrors.length !== 0) {
-      return {
-        'validDomains': {
-          reason: 'invalid',
-          value: newHostsErrors.join('. ') + '.'
-        }
-      }
-    }
-
-    /* Is valid. */
-    return null
-  }
-
-  private isHostsUnique: ValidatorFn = (control) => {
-    if (!control.value) return null
-
-    const hosts = this.getNotEmptyHosts(control.value)
-
-    if (hosts.every((host: string) => hosts.indexOf(host) === hosts.lastIndexOf(host))) {
-      return null
-    } else {
-      return {
-        'uniqueDomains': {
-          reason: 'invalid'
-        }
-      }
-    }
-  }
-}
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 (file)
index 862ff54..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class CustomConfigValidatorsService {
-  readonly INSTANCE_NAME: BuildFormValidator
-  readonly INSTANCE_SHORT_DESCRIPTION: BuildFormValidator
-  readonly SERVICES_TWITTER_USERNAME: BuildFormValidator
-  readonly CACHE_PREVIEWS_SIZE: BuildFormValidator
-  readonly CACHE_CAPTIONS_SIZE: BuildFormValidator
-  readonly SIGNUP_LIMIT: BuildFormValidator
-  readonly ADMIN_EMAIL: BuildFormValidator
-  readonly TRANSCODING_THREADS: BuildFormValidator
-  readonly INDEX_URL: BuildFormValidator
-  readonly SEARCH_INDEX_URL: BuildFormValidator
-
-  constructor () {
-    this.INSTANCE_NAME = {
-      VALIDATORS: [ Validators.required ],
-      MESSAGES: {
-        'required': $localize`Instance name is required.`
-      }
-    }
-
-    this.INSTANCE_SHORT_DESCRIPTION = {
-      VALIDATORS: [ Validators.max(250) ],
-      MESSAGES: {
-        'max': $localize`Short description should not be longer than 250 characters.`
-      }
-    }
-
-    this.SERVICES_TWITTER_USERNAME = {
-      VALIDATORS: [ Validators.required ],
-      MESSAGES: {
-        'required': $localize`Twitter username is required.`
-      }
-    }
-
-    this.CACHE_PREVIEWS_SIZE = {
-      VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
-      MESSAGES: {
-        'required': $localize`Previews cache size is required.`,
-        'min': $localize`Previews cache size must be greater than 1.`,
-        'pattern': $localize`Previews cache size must be a number.`
-      }
-    }
-
-    this.CACHE_CAPTIONS_SIZE = {
-      VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
-      MESSAGES: {
-        'required': $localize`Captions cache size is required.`,
-        'min': $localize`Captions cache size must be greater than 1.`,
-        'pattern': $localize`Captions cache size must be a number.`
-      }
-    }
-
-    this.SIGNUP_LIMIT = {
-      VALIDATORS: [ Validators.required, Validators.min(-1), Validators.pattern('-?[0-9]+') ],
-      MESSAGES: {
-        'required': $localize`Signup limit is required.`,
-        'min': $localize`Signup limit must be greater than 1.`,
-        'pattern': $localize`Signup limit must be a number.`
-      }
-    }
-
-    this.ADMIN_EMAIL = {
-      VALIDATORS: [ Validators.required, Validators.email ],
-      MESSAGES: {
-        'required': $localize`Admin email is required.`,
-        'email': $localize`Admin email must be valid.`
-      }
-    }
-
-    this.TRANSCODING_THREADS = {
-      VALIDATORS: [ Validators.required, Validators.min(0) ],
-      MESSAGES: {
-        'required': $localize`Transcoding threads is required.`,
-        'min': $localize`Transcoding threads must be greater or equal to 0.`
-      }
-    }
-
-    this.INDEX_URL = {
-      VALIDATORS: [ Validators.pattern(/^https:\/\//) ],
-      MESSAGES: {
-        'pattern': $localize`Index URL should be a URL`
-      }
-    }
-
-    this.SEARCH_INDEX_URL = {
-      VALIDATORS: [ Validators.pattern(/^https?:\/\//) ],
-      MESSAGES: {
-        'pattern': $localize`Search index URL should be a URL`
-      }
-    }
-  }
-}
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 (file)
index b06a326..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-export * from './abuse-validators.service'
-export * from './batch-domains-validators.service'
-export * from './custom-config-validators.service'
-export * from './form-validator.service'
-export * from './host'
-export * from './instance-validators.service'
-export * from './login-validators.service'
-export * from './reset-password-validators.service'
-export * from './user-validators.service'
-export * from './video-accept-ownership-validators.service'
-export * from './video-block-validators.service'
-export * from './video-captions-validators.service'
-export * from './video-change-ownership-validators.service'
-export * from './video-channel-validators.service'
-export * from './video-comment-validators.service'
-export * from './video-playlist-validators.service'
-export * 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 (file)
index 3628f0b..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class InstanceValidatorsService {
-  readonly FROM_EMAIL: BuildFormValidator
-  readonly FROM_NAME: BuildFormValidator
-  readonly SUBJECT: BuildFormValidator
-  readonly BODY: BuildFormValidator
-
-  constructor () {
-
-    this.FROM_EMAIL = {
-      VALIDATORS: [ Validators.required, Validators.email ],
-      MESSAGES: {
-        'required': $localize`Email is required.`,
-        'email': $localize`Email must be valid.`
-      }
-    }
-
-    this.FROM_NAME = {
-      VALIDATORS: [
-        Validators.required,
-        Validators.minLength(1),
-        Validators.maxLength(120)
-      ],
-      MESSAGES: {
-        'required': $localize`Your name is required.`,
-        'minlength': $localize`Your name must be at least 1 character long.`,
-        'maxlength': $localize`Your name cannot be more than 120 characters long.`
-      }
-    }
-
-    this.SUBJECT = {
-      VALIDATORS: [
-        Validators.required,
-        Validators.minLength(1),
-        Validators.maxLength(120)
-      ],
-      MESSAGES: {
-        'required': $localize`A subject is required.`,
-        'minlength': $localize`The subject must be at least 1 character long.`,
-        'maxlength': $localize`The subject cannot be more than 120 characters long.`
-      }
-    }
-
-    this.BODY = {
-      VALIDATORS: [
-        Validators.required,
-        Validators.minLength(3),
-        Validators.maxLength(5000)
-      ],
-      MESSAGES: {
-        'required': $localize`A message is required.`,
-        'minlength': $localize`The message must be at least 3 characters long.`,
-        'maxlength': $localize`The message cannot be more than 5000 characters long.`
-      }
-    }
-  }
-}
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 (file)
index 67ea11f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class LoginValidatorsService {
-  readonly LOGIN_USERNAME: BuildFormValidator
-  readonly LOGIN_PASSWORD: BuildFormValidator
-
-  constructor () {
-    this.LOGIN_USERNAME = {
-      VALIDATORS: [
-        Validators.required
-      ],
-      MESSAGES: {
-        'required': $localize`Username is required.`
-      }
-    }
-
-    this.LOGIN_PASSWORD = {
-      VALIDATORS: [
-        Validators.required
-      ],
-      MESSAGES: {
-        'required': $localize`Password is required.`
-      }
-    }
-  }
-}
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 (file)
index 3d0b4dd..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class ResetPasswordValidatorsService {
-  readonly RESET_PASSWORD_CONFIRM: BuildFormValidator
-
-  constructor () {
-    this.RESET_PASSWORD_CONFIRM = {
-      VALIDATORS: [
-        Validators.required
-      ],
-      MESSAGES: {
-        'required': $localize`Confirmation of the password is required.`
-      }
-    }
-  }
-}
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 (file)
index 312fc9b..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class UserValidatorsService {
-  readonly USER_USERNAME: BuildFormValidator
-  readonly USER_CHANNEL_NAME: BuildFormValidator
-  readonly USER_EMAIL: BuildFormValidator
-  readonly USER_PASSWORD: BuildFormValidator
-  readonly USER_PASSWORD_OPTIONAL: BuildFormValidator
-  readonly USER_CONFIRM_PASSWORD: BuildFormValidator
-  readonly USER_VIDEO_QUOTA: BuildFormValidator
-  readonly USER_VIDEO_QUOTA_DAILY: BuildFormValidator
-  readonly USER_ROLE: BuildFormValidator
-  readonly USER_DISPLAY_NAME_REQUIRED: BuildFormValidator
-  readonly USER_DESCRIPTION: BuildFormValidator
-  readonly USER_TERMS: BuildFormValidator
-
-  readonly USER_BAN_REASON: BuildFormValidator
-
-  constructor () {
-
-    this.USER_USERNAME = {
-      VALIDATORS: [
-        Validators.required,
-        Validators.minLength(1),
-        Validators.maxLength(50),
-        Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
-      ],
-      MESSAGES: {
-        'required': $localize`Username is required.`,
-        'minlength': $localize`Username must be at least 1 character long.`,
-        'maxlength': $localize`Username cannot be more than 50 characters long.`,
-        'pattern': $localize`Username should be lowercase alphanumeric; dots and underscores are allowed.`
-      }
-    }
-
-    this.USER_CHANNEL_NAME = {
-      VALIDATORS: [
-        Validators.required,
-        Validators.minLength(1),
-        Validators.maxLength(50),
-        Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
-      ],
-      MESSAGES: {
-        'required': $localize`Channel name is required.`,
-        'minlength': $localize`Channel name must be at least 1 character long.`,
-        'maxlength': $localize`Channel name cannot be more than 50 characters long.`,
-        'pattern': $localize`Channel name should be lowercase alphanumeric; dots and underscores are allowed.`
-      }
-    }
-
-    this.USER_EMAIL = {
-      VALIDATORS: [ Validators.required, Validators.email ],
-      MESSAGES: {
-        'required': $localize`Email is required.`,
-        'email': $localize`Email must be valid.`
-      }
-    }
-
-    this.USER_PASSWORD = {
-      VALIDATORS: [
-        Validators.required,
-        Validators.minLength(6),
-        Validators.maxLength(255)
-      ],
-      MESSAGES: {
-        'required': $localize`Password is required.`,
-        'minlength': $localize`Password must be at least 6 characters long.`,
-        'maxlength': $localize`Password cannot be more than 255 characters long.`
-      }
-    }
-
-    this.USER_PASSWORD_OPTIONAL = {
-      VALIDATORS: [
-        Validators.minLength(6),
-        Validators.maxLength(255)
-      ],
-      MESSAGES: {
-        'minlength': $localize`Password must be at least 6 characters long.`,
-        'maxlength': $localize`Password cannot be more than 255 characters long.`
-      }
-    }
-
-    this.USER_CONFIRM_PASSWORD = {
-      VALIDATORS: [],
-      MESSAGES: {
-        'matchPassword': $localize`The new password and the confirmed password do not correspond.`
-      }
-    }
-
-    this.USER_VIDEO_QUOTA = {
-      VALIDATORS: [ Validators.required, Validators.min(-1) ],
-      MESSAGES: {
-        'required': $localize`Video quota is required.`,
-        'min': $localize`Quota must be greater than -1.`
-      }
-    }
-    this.USER_VIDEO_QUOTA_DAILY = {
-      VALIDATORS: [ Validators.required, Validators.min(-1) ],
-      MESSAGES: {
-        'required': $localize`Daily upload limit is required.`,
-        'min': $localize`Daily upload limit must be greater than -1.`
-      }
-    }
-
-    this.USER_ROLE = {
-      VALIDATORS: [ Validators.required ],
-      MESSAGES: {
-        'required': $localize`User role is required.`
-      }
-    }
-
-    this.USER_DISPLAY_NAME_REQUIRED = this.getDisplayName(true)
-
-    this.USER_DESCRIPTION = {
-      VALIDATORS: [
-        Validators.minLength(3),
-        Validators.maxLength(1000)
-      ],
-      MESSAGES: {
-        'minlength': $localize`Description must be at least 3 characters long.`,
-        'maxlength': $localize`Description cannot be more than 1000 characters long.`
-      }
-    }
-
-    this.USER_TERMS = {
-      VALIDATORS: [
-        Validators.requiredTrue
-      ],
-      MESSAGES: {
-        'required': $localize`You must agree with the instance terms in order to register on it.`
-      }
-    }
-
-    this.USER_BAN_REASON = {
-      VALIDATORS: [
-        Validators.minLength(3),
-        Validators.maxLength(250)
-      ],
-      MESSAGES: {
-        'minlength': $localize`Ban reason must be at least 3 characters long.`,
-        'maxlength': $localize`Ban reason cannot be more than 250 characters long.`
-      }
-    }
-  }
-
-  private getDisplayName (required: boolean) {
-    const control = {
-      VALIDATORS: [
-        Validators.minLength(1),
-        Validators.maxLength(120)
-      ],
-      MESSAGES: {
-        'required': $localize`Display name is required.`,
-        'minlength': $localize`Display name must be at least 1 character long.`,
-        'maxlength': $localize`Display name cannot be more than 50 characters long.`
-      }
-    }
-
-    if (required) control.VALIDATORS.push(Validators.required)
-
-    return control
-  }
-}
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 (file)
index aed9e9c..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoAcceptOwnershipValidatorsService {
-  readonly CHANNEL: BuildFormValidator
-
-  constructor () {
-    this.CHANNEL = {
-      VALIDATORS: [ Validators.required ],
-      MESSAGES: {
-        'required': $localize`The channel is required.`
-      }
-    }
-  }
-}
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 (file)
index bce1880..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoBlockValidatorsService {
-  readonly VIDEO_BLOCK_REASON: BuildFormValidator
-
-  constructor () {
-    this.VIDEO_BLOCK_REASON = {
-      VALIDATORS: [ Validators.minLength(2), Validators.maxLength(300) ],
-      MESSAGES: {
-        'minlength': $localize`Block reason must be at least 2 characters long.`,
-        'maxlength': $localize`Block reason cannot be more than 300 characters long.`
-      }
-    }
-  }
-}
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 (file)
index 7e90264..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoCaptionsValidatorsService {
-  readonly VIDEO_CAPTION_LANGUAGE: BuildFormValidator
-  readonly VIDEO_CAPTION_FILE: BuildFormValidator
-
-  constructor () {
-
-    this.VIDEO_CAPTION_LANGUAGE = {
-      VALIDATORS: [ Validators.required ],
-      MESSAGES: {
-        'required': $localize`Video caption language is required.`
-      }
-    }
-
-    this.VIDEO_CAPTION_FILE = {
-      VALIDATORS: [ Validators.required ],
-      MESSAGES: {
-        'required': $localize`Video caption file is required.`
-      }
-    }
-  }
-}
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 (file)
index 8c809a0..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-import { Injectable } from '@angular/core'
-import { AbstractControl, ValidationErrors, Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoChangeOwnershipValidatorsService {
-  readonly USERNAME: BuildFormValidator
-
-  constructor () {
-    this.USERNAME = {
-      VALIDATORS: [ Validators.required, this.localAccountValidator ],
-      MESSAGES: {
-        'required': $localize`The username is required.`,
-        'localAccountOnly': $localize`You can only transfer ownership to a local account`
-      }
-    }
-  }
-
-  localAccountValidator (control: AbstractControl): ValidationErrors {
-    if (control.value.includes('@')) {
-      return { 'localAccountOnly': true }
-    }
-
-    return null
-  }
-}
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 (file)
index 3e74441..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoChannelValidatorsService {
-  readonly VIDEO_CHANNEL_NAME: BuildFormValidator
-  readonly VIDEO_CHANNEL_DISPLAY_NAME: BuildFormValidator
-  readonly VIDEO_CHANNEL_DESCRIPTION: BuildFormValidator
-  readonly VIDEO_CHANNEL_SUPPORT: BuildFormValidator
-
-  constructor () {
-    this.VIDEO_CHANNEL_NAME = {
-      VALIDATORS: [
-        Validators.required,
-        Validators.minLength(1),
-        Validators.maxLength(50),
-        Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
-      ],
-      MESSAGES: {
-        'required': $localize`Name is required.`,
-        'minlength': $localize`Name must be at least 1 character long.`,
-        'maxlength': $localize`Name cannot be more than 50 characters long.`,
-        'pattern': $localize`Name should be lowercase alphanumeric; dots and underscores are allowed.`
-      }
-    }
-
-    this.VIDEO_CHANNEL_DISPLAY_NAME = {
-      VALIDATORS: [
-        Validators.required,
-        Validators.minLength(1),
-        Validators.maxLength(50)
-      ],
-      MESSAGES: {
-        'required': $localize`Display name is required.`,
-        'minlength': $localize`Display name must be at least 1 character long.`,
-        'maxlength': $localize`Display name cannot be more than 50 characters long.`
-      }
-    }
-
-    this.VIDEO_CHANNEL_DESCRIPTION = {
-      VALIDATORS: [
-        Validators.minLength(3),
-        Validators.maxLength(1000)
-      ],
-      MESSAGES: {
-        'minlength': $localize`Description must be at least 3 characters long.`,
-        'maxlength': $localize`Description cannot be more than 1000 characters long.`
-      }
-    }
-
-    this.VIDEO_CHANNEL_SUPPORT = {
-      VALIDATORS: [
-        Validators.minLength(3),
-        Validators.maxLength(1000)
-      ],
-      MESSAGES: {
-        'minlength': $localize`Support text must be at least 3 characters long.`,
-        'maxlength': $localize`Support text cannot be more than 1000 characters long`
-      }
-    }
-  }
-}
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 (file)
index 18e7ae2..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoCommentValidatorsService {
-  readonly VIDEO_COMMENT_TEXT: BuildFormValidator
-
-  constructor () {
-    this.VIDEO_COMMENT_TEXT = {
-      VALIDATORS: [ Validators.required, Validators.minLength(1), Validators.maxLength(3000) ],
-      MESSAGES: {
-        'required': $localize`Comment is required.`,
-        'minlength': $localize`Comment must be at least 2 characters long.`,
-        'maxlength': $localize`Comment cannot be more than 3000 characters long.`
-      }
-    }
-  }
-}
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 (file)
index 3b45a40..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-import { Injectable } from '@angular/core'
-import { AbstractControl, Validators } from '@angular/forms'
-import { VideoPlaylistPrivacy } from '@shared/models'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoPlaylistValidatorsService {
-  readonly VIDEO_PLAYLIST_DISPLAY_NAME: BuildFormValidator
-  readonly VIDEO_PLAYLIST_PRIVACY: BuildFormValidator
-  readonly VIDEO_PLAYLIST_DESCRIPTION: BuildFormValidator
-  readonly VIDEO_PLAYLIST_CHANNEL_ID: BuildFormValidator
-
-  constructor () {
-    this.VIDEO_PLAYLIST_DISPLAY_NAME = {
-      VALIDATORS: [
-        Validators.required,
-        Validators.minLength(1),
-        Validators.maxLength(120)
-      ],
-      MESSAGES: {
-        'required': $localize`Display name is required.`,
-        'minlength': $localize`Display name must be at least 1 character long.`,
-        'maxlength': $localize`Display name cannot be more than 120 characters long.`
-      }
-    }
-
-    this.VIDEO_PLAYLIST_PRIVACY = {
-      VALIDATORS: [
-        Validators.required
-      ],
-      MESSAGES: {
-        'required': $localize`Privacy is required.`
-      }
-    }
-
-    this.VIDEO_PLAYLIST_DESCRIPTION = {
-      VALIDATORS: [
-        Validators.minLength(3),
-        Validators.maxLength(1000)
-      ],
-      MESSAGES: {
-        'minlength': $localize`Description must be at least 3 characters long.`,
-        'maxlength': $localize`Description cannot be more than 1000 characters long.`
-      }
-    }
-
-    this.VIDEO_PLAYLIST_CHANNEL_ID = {
-      VALIDATORS: [ ],
-      MESSAGES: {
-        'required': $localize`The channel is required when the playlist is public.`
-      }
-    }
-  }
-
-  setChannelValidator (channelControl: AbstractControl, privacy: VideoPlaylistPrivacy) {
-    if (privacy.toString() === VideoPlaylistPrivacy.PUBLIC.toString()) {
-      channelControl.setValidators([ Validators.required ])
-    } else {
-      channelControl.setValidators(null)
-    }
-
-    channelControl.markAsDirty()
-    channelControl.updateValueAndValidity()
-  }
-}
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 (file)
index 8119c1a..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-import { Injectable } from '@angular/core'
-import { AbstractControl, ValidationErrors, ValidatorFn, Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoValidatorsService {
-  readonly VIDEO_NAME: BuildFormValidator
-  readonly VIDEO_PRIVACY: BuildFormValidator
-  readonly VIDEO_CATEGORY: BuildFormValidator
-  readonly VIDEO_LICENCE: BuildFormValidator
-  readonly VIDEO_LANGUAGE: BuildFormValidator
-  readonly VIDEO_IMAGE: BuildFormValidator
-  readonly VIDEO_CHANNEL: BuildFormValidator
-  readonly VIDEO_DESCRIPTION: BuildFormValidator
-  readonly VIDEO_TAGS_ARRAY: BuildFormValidator
-  readonly VIDEO_TAG: BuildFormValidator
-  readonly VIDEO_SUPPORT: BuildFormValidator
-  readonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator
-  readonly VIDEO_ORIGINALLY_PUBLISHED_AT: BuildFormValidator
-
-  constructor () {
-
-    this.VIDEO_NAME = {
-      VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ],
-      MESSAGES: {
-        'required': $localize`Video name is required.`,
-        'minlength': $localize`Video name must be at least 3 characters long.`,
-        'maxlength': $localize`Video name cannot be more than 120 characters long.`
-      }
-    }
-
-    this.VIDEO_PRIVACY = {
-      VALIDATORS: [ Validators.required ],
-      MESSAGES: {
-        'required': $localize`Video privacy is required.`
-      }
-    }
-
-    this.VIDEO_CATEGORY = {
-      VALIDATORS: [ ],
-      MESSAGES: {}
-    }
-
-    this.VIDEO_LICENCE = {
-      VALIDATORS: [ ],
-      MESSAGES: {}
-    }
-
-    this.VIDEO_LANGUAGE = {
-      VALIDATORS: [ ],
-      MESSAGES: {}
-    }
-
-    this.VIDEO_IMAGE = {
-      VALIDATORS: [ ],
-      MESSAGES: {}
-    }
-
-    this.VIDEO_CHANNEL = {
-      VALIDATORS: [ Validators.required ],
-      MESSAGES: {
-        'required': $localize`Video channel is required.`
-      }
-    }
-
-    this.VIDEO_DESCRIPTION = {
-      VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ],
-      MESSAGES: {
-        'minlength': $localize`Video description must be at least 3 characters long.`,
-        'maxlength': $localize`Video description cannot be more than 10000 characters long.`
-      }
-    }
-
-    this.VIDEO_TAG = {
-      VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ],
-      MESSAGES: {
-        'minlength': $localize`A tag should be more than 2 characters long.`,
-        'maxlength': $localize`A tag should be less than 30 characters long.`
-      }
-    }
-
-    this.VIDEO_TAGS_ARRAY = {
-      VALIDATORS: [ Validators.maxLength(5), this.arrayTagLengthValidator() ],
-      MESSAGES: {
-        'maxlength': $localize`A maximum of 5 tags can be used on a video.`,
-        'arrayTagLength': $localize`A tag should be more than 2, and less than 30 characters long.`
-      }
-    }
-
-    this.VIDEO_SUPPORT = {
-      VALIDATORS: [ Validators.minLength(3), Validators.maxLength(1000) ],
-      MESSAGES: {
-        'minlength': $localize`Video support must be at least 3 characters long.`,
-        'maxlength': $localize`Video support cannot be more than 1000 characters long.`
-      }
-    }
-
-    this.VIDEO_SCHEDULE_PUBLICATION_AT = {
-      VALIDATORS: [ ],
-      MESSAGES: {
-        'required': $localize`A date is required to schedule video update.`
-      }
-    }
-
-    this.VIDEO_ORIGINALLY_PUBLISHED_AT = {
-      VALIDATORS: [ ],
-      MESSAGES: {}
-    }
-  }
-
-  arrayTagLengthValidator (min = 2, max = 30): ValidatorFn {
-    return (control: AbstractControl): ValidationErrors => {
-      const array = control.value as Array<string>
-
-      if (array.every(e => e.length > min && e.length < max)) {
-        return null
-      }
-
-      return { 'arrayTagLength': true }
-    }
-  }
-}
index 747df65cf7399bdd471445ba82c243e3e38d925b..b2c7fa9ba8761b5ec74b0cdea0e4bb2144633838 100644 (file)
@@ -1,4 +1,4 @@
-export * from './form-validators'
+export * from './form-validator.service'
 export * from './form-reactive'
 export * from './select'
 export * from './input-readonly-copy.component'
index 0e0ed5babeebaad2bb85da6c463d3ae9143e7d7c..1946ac21f078aabe3547e7b66fd8a5a87ad2c1f9 100644 (file)
@@ -1,37 +1,20 @@
 
-import { NgModule } from '@angular/core'
-import { FormsModule, ReactiveFormsModule } from '@angular/forms'
 import { InputMaskModule } from 'primeng/inputmask'
 import { InputSwitchModule } from 'primeng/inputswitch'
+import { NgModule } from '@angular/core'
+import { FormsModule, ReactiveFormsModule } from '@angular/forms'
 import { NgSelectModule } from '@ng-select/ng-select'
-import { BatchDomainsValidatorsService } from '@app/shared/shared-forms/form-validators/batch-domains-validators.service'
 import { SharedGlobalIconModule } from '../shared-icons'
 import { SharedMainModule } from '../shared-main/shared-main.module'
-import {
-  CustomConfigValidatorsService,
-  FormValidatorService,
-  InstanceValidatorsService,
-  LoginValidatorsService,
-  ResetPasswordValidatorsService,
-  UserValidatorsService,
-  AbuseValidatorsService,
-  VideoAcceptOwnershipValidatorsService,
-  VideoBlockValidatorsService,
-  VideoCaptionsValidatorsService,
-  VideoChangeOwnershipValidatorsService,
-  VideoChannelValidatorsService,
-  VideoCommentValidatorsService,
-  VideoPlaylistValidatorsService,
-  VideoValidatorsService
-} from './form-validators'
+import { FormValidatorService } from './form-validator.service'
 import { InputReadonlyCopyComponent } from './input-readonly-copy.component'
 import { MarkdownTextareaComponent } from './markdown-textarea.component'
 import { PeertubeCheckboxComponent } from './peertube-checkbox.component'
 import { PreviewUploadComponent } from './preview-upload.component'
 import { ReactiveFileComponent } from './reactive-file.component'
+import { SelectChannelComponent, SelectCheckboxComponent, SelectOptionsComponent, SelectTagsComponent } from './select'
 import { TextareaAutoResizeDirective } from './textarea-autoresize.directive'
 import { TimestampInputComponent } from './timestamp-input.component'
-import { SelectChannelComponent, SelectCheckboxComponent, SelectOptionsComponent, SelectTagsComponent } from './select'
 
 @NgModule({
   imports: [
@@ -84,23 +67,7 @@ import { SelectChannelComponent, SelectCheckboxComponent, SelectOptionsComponent
   ],
 
   providers: [
-    CustomConfigValidatorsService,
-    FormValidatorService,
-    LoginValidatorsService,
-    InstanceValidatorsService,
-    LoginValidatorsService,
-    ResetPasswordValidatorsService,
-    UserValidatorsService,
-    AbuseValidatorsService,
-    VideoAcceptOwnershipValidatorsService,
-    VideoBlockValidatorsService,
-    VideoCaptionsValidatorsService,
-    VideoChangeOwnershipValidatorsService,
-    VideoChannelValidatorsService,
-    VideoCommentValidatorsService,
-    VideoPlaylistValidatorsService,
-    VideoValidatorsService,
-    BatchDomainsValidatorsService
+    FormValidatorService
   ]
 })
 export class SharedFormModule { }
index 7193ccb1b12e189e78b5401504e6672258db3137..6edbb602328380ec11dbab454554818b233d3659 100644 (file)
@@ -1,7 +1,8 @@
 import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
-import { BatchDomainsValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
+import { DOMAINS_VALIDATOR, getNotEmptyHosts } from '../form-validators/batch-domains-validators'
 
 @Component({
   selector: 'my-batch-domains-modal',
@@ -18,8 +19,7 @@ export class BatchDomainsModalComponent extends FormReactive implements OnInit {
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private modalService: NgbModal,
-    private batchDomainsValidatorsService: BatchDomainsValidatorsService
+    private modalService: NgbModal
   ) {
     super()
   }
@@ -28,7 +28,7 @@ export class BatchDomainsModalComponent extends FormReactive implements OnInit {
     if (!this.action) this.action = $localize`Process domains`
 
     this.buildForm({
-      domains: this.batchDomainsValidatorsService.DOMAINS
+      domains: DOMAINS_VALIDATOR
     })
   }
 
@@ -42,7 +42,7 @@ export class BatchDomainsModalComponent extends FormReactive implements OnInit {
 
   submit () {
     this.domains.emit(
-      this.batchDomainsValidatorsService.getNotEmptyHosts(this.form.controls['domains'].value)
+      getNotEmptyHosts(this.form.controls['domains'].value)
     )
     this.form.reset()
     this.hide()
index 8ab2fe940af8734b77dd198cbec4bc3b94e0a28d..cc8875f7742c27635c05b0c3cbd6d3e797a7b1e6 100644 (file)
@@ -1,7 +1,8 @@
 import { mapValues, pickBy } from 'lodash-es'
 import { Component, Input, OnInit, ViewChild } from '@angular/core'
 import { Notifier } from '@app/core'
-import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { Account } from '@app/shared/shared-main'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
@@ -28,7 +29,6 @@ export class AccountReportComponent extends FormReactive implements OnInit {
   constructor (
     protected formValidatorService: FormValidatorService,
     private modalService: NgbModal,
-    private abuseValidatorsService: AbuseValidatorsService,
     private abuseService: AbuseService,
     private notifier: Notifier
   ) {
@@ -51,7 +51,7 @@ export class AccountReportComponent extends FormReactive implements OnInit {
     this.modalTitle = $localize`Report ${this.account.displayName}`
 
     this.buildForm({
-      reason: this.abuseValidatorsService.ABUSE_REASON,
+      reason: ABUSE_REASON_VALIDATOR,
       predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null)
     })
 
index d75f4d7173293f05d410dff3a5d1e2dc34b268b0..c7395c7b756ebde9674cea83971708b7c36e65ed 100644 (file)
@@ -1,7 +1,8 @@
 import { mapValues, pickBy } from 'lodash-es'
 import { Component, Input, OnInit, ViewChild } from '@angular/core'
 import { Notifier } from '@app/core'
-import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { VideoComment } from '@app/shared/shared-video-comment'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
@@ -28,7 +29,6 @@ export class CommentReportComponent extends FormReactive implements OnInit {
   constructor (
     protected formValidatorService: FormValidatorService,
     private modalService: NgbModal,
-    private abuseValidatorsService: AbuseValidatorsService,
     private abuseService: AbuseService,
     private notifier: Notifier
   ) {
@@ -51,7 +51,7 @@ export class CommentReportComponent extends FormReactive implements OnInit {
     this.modalTitle = $localize`Report comment`
 
     this.buildForm({
-      reason: this.abuseValidatorsService.ABUSE_REASON,
+      reason: ABUSE_REASON_VALIDATOR,
       predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null)
     })
 
index edff6d325fd6575ab67e55b4c1a2a26b41f8ac9a..5b06c0bc7e07c8893af3633c126349a48f463d7b 100644 (file)
@@ -3,7 +3,8 @@ import { buildVideoLink, buildVideoOrPlaylistEmbed } from 'src/assets/player/uti
 import { Component, Input, OnInit, ViewChild } from '@angular/core'
 import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
 import { Notifier } from '@app/core'
-import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
 import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
@@ -30,7 +31,6 @@ export class VideoReportComponent extends FormReactive implements OnInit {
   constructor (
     protected formValidatorService: FormValidatorService,
     private modalService: NgbModal,
-    private abuseValidatorsService: AbuseValidatorsService,
     private abuseService: AbuseService,
     private notifier: Notifier,
     private sanitizer: DomSanitizer
@@ -68,7 +68,7 @@ export class VideoReportComponent extends FormReactive implements OnInit {
 
   ngOnInit () {
     this.buildForm({
-      reason: this.abuseValidatorsService.ABUSE_REASON,
+      reason: ABUSE_REASON_VALIDATOR,
       predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null),
       timestamp: {
         hasStart: null,
index f9a0381c5b0383db1aeeb8df0288fb23ff2c5e70..afc69a1b89742235ee5d34e0a80cf93385ec5e1e 100644 (file)
@@ -1,9 +1,10 @@
 import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
 import { Notifier, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
 import { User } from '@shared/models'
+import { USER_BAN_REASON_VALIDATOR } from '../form-validators/user-validators'
 
 @Component({
   selector: 'my-user-ban-modal',
@@ -21,15 +22,14 @@ export class UserBanModalComponent extends FormReactive implements OnInit {
     protected formValidatorService: FormValidatorService,
     private modalService: NgbModal,
     private notifier: Notifier,
-    private userService: UserService,
-    private userValidatorsService: UserValidatorsService
+    private userService: UserService
   ) {
     super()
   }
 
   ngOnInit () {
     this.buildForm({
-      reason: this.userValidatorsService.USER_BAN_REASON
+      reason: USER_BAN_REASON_VALIDATOR
     })
   }
 
index 2bef9efdd770b5a11a41fdc9ff9e085b412c0625..fb47989dc23394b9bb8fb1a3ac16fe9b2b3f1db0 100644 (file)
@@ -1,9 +1,10 @@
 import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
 import { Notifier } from '@app/core'
-import { FormReactive, FormValidatorService, VideoBlockValidatorsService } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { Video } from '@app/shared/shared-main'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
+import { VIDEO_BLOCK_REASON_VALIDATOR } from '../form-validators/video-block-validators'
 import { VideoBlockService } from './video-block.service'
 
 @Component({
@@ -25,7 +26,6 @@ export class VideoBlockComponent extends FormReactive implements OnInit {
   constructor (
     protected formValidatorService: FormValidatorService,
     private modalService: NgbModal,
-    private videoBlockValidatorsService: VideoBlockValidatorsService,
     private videoBlocklistService: VideoBlockService,
     private notifier: Notifier
   ) {
@@ -36,7 +36,7 @@ export class VideoBlockComponent extends FormReactive implements OnInit {
     const defaultValues = { unfederate: 'true' }
 
     this.buildForm({
-      reason: this.videoBlockValidatorsService.VIDEO_BLOCK_REASON,
+      reason: VIDEO_BLOCK_REASON_VALIDATOR,
       unfederate: null
     }, defaultValues)
   }
index 286ecac029bdb1465e85b855e5be9d2b809daaba..b46c91bf8bd496a1352c8992575841016c17c2aa 100644 (file)
@@ -1,5 +1,6 @@
 import { Component, Input, OnInit } from '@angular/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { USER_EMAIL_VALIDATOR } from '../form-validators/user-validators'
 
 @Component({
   selector: 'my-remote-subscribe',
@@ -12,15 +13,14 @@ export class RemoteSubscribeComponent extends FormReactive implements OnInit {
   @Input() showHelp = false
 
   constructor (
-    protected formValidatorService: FormValidatorService,
-    private userValidatorsService: UserValidatorsService
+    protected formValidatorService: FormValidatorService
   ) {
     super()
   }
 
   ngOnInit () {
     this.buildForm({
-      text: this.userValidatorsService.USER_EMAIL
+      text: USER_EMAIL_VALIDATOR
     })
   }
 
index 757ffa099791eafe62ac735cb0c49ee16cfb31e5..41f16e0bfe78e173d6935b2e7cc3fffcf58b6952 100644 (file)
@@ -3,9 +3,10 @@ import { Subject, Subscription } from 'rxjs'
 import { debounceTime, filter } from 'rxjs/operators'
 import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'
 import { AuthService, DisableForReuseHook, Notifier } from '@app/core'
-import { FormReactive, FormValidatorService, VideoPlaylistValidatorsService } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { Video, VideoExistInPlaylist, VideoPlaylistCreate, VideoPlaylistElementCreate, VideoPlaylistPrivacy } from '@shared/models'
 import { secondsToTime } from '../../../assets/player/utils'
+import { VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR } from '../form-validators/video-playlist-validators'
 import { CachedPlaylist, VideoPlaylistService } from './video-playlist.service'
 
 const logger = debug('peertube:playlists:VideoAddToPlaylistComponent')
@@ -53,7 +54,6 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
     private authService: AuthService,
     private notifier: Notifier,
     private videoPlaylistService: VideoPlaylistService,
-    private videoPlaylistValidatorsService: VideoPlaylistValidatorsService,
     private cd: ChangeDetectorRef
   ) {
     super()
@@ -65,7 +65,7 @@ export class VideoAddToPlaylistComponent extends FormReactive implements OnInit,
 
   ngOnInit () {
     this.buildForm({
-      displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME
+      displayName: VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR
     })
 
     this.videoPlaylistService.listenToMyAccountPlaylistsChange()