]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/form-validators/custom-config-validators.ts
Increase theme compatibility
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / form-validators / custom-config-validators.ts
index ef6e9b456ead9148b70fe08d8a67c1e0249e1a72..ff0813f7d821e53cd133d00e6708149c74154963 100644 (file)
@@ -2,111 +2,129 @@ import { Validators } from '@angular/forms'
 import { BuildFormValidator } from './form-validator.model'
 
 export const INSTANCE_NAME_VALIDATOR: BuildFormValidator = {
-  VALIDATORS: [Validators.required],
+  VALIDATORS: [ Validators.required ],
   MESSAGES: {
-    'required': $localize`Instance name is required.`
+    required: $localize`Instance name is required.`
   }
 }
 
 export const INSTANCE_SHORT_DESCRIPTION_VALIDATOR: BuildFormValidator = {
-  VALIDATORS: [Validators.max(250)],
+  VALIDATORS: [ Validators.maxLength(250) ],
   MESSAGES: {
-    'max': $localize`Short description should not be longer than 250 characters.`
+    maxlength: $localize`Short description should not be longer than 250 characters.`
   }
 }
 
 export const SERVICES_TWITTER_USERNAME_VALIDATOR: BuildFormValidator = {
-  VALIDATORS: [Validators.required],
+  VALIDATORS: [ Validators.required ],
   MESSAGES: {
-    'required': $localize`Twitter username is required.`
+    required: $localize`Twitter username is required.`
   }
 }
 
 export const CACHE_PREVIEWS_SIZE_VALIDATOR: BuildFormValidator = {
-  VALIDATORS: [Validators.required, Validators.min(1), Validators.pattern('[0-9]+')],
+  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.`
+    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]+')],
+  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.`
+    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]+')],
+  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. Use -1 to disable it.`,
-    'pattern': $localize`Signup limit must be a number.`
+    required: $localize`Signup limit is required.`,
+    min: $localize`Signup limit must be greater than 1. Use -1 to disable it.`,
+    pattern: $localize`Signup limit must be a number.`
+  }
+}
+
+export const SIGNUP_MINIMUM_AGE_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
+  MESSAGES: {
+    required: $localize`Signup minimum age is required.`,
+    min: $localize`Signup minimum age must be greater than 1.`,
+    pattern: $localize`Signup minimum age must be a number.`
   }
 }
 
 export const ADMIN_EMAIL_VALIDATOR: BuildFormValidator = {
-  VALIDATORS: [Validators.required, Validators.email],
+  VALIDATORS: [ Validators.required, Validators.email ],
   MESSAGES: {
-    'required': $localize`Admin email is required.`,
-    'email': $localize`Admin email must be valid.`
+    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)],
+  VALIDATORS: [ Validators.required, Validators.min(0) ],
   MESSAGES: {
-    'required': $localize`Transcoding threads is required.`,
-    'min': $localize`Transcoding threads must be greater or equal to 0.`
+    required: $localize`Transcoding threads is required.`,
+    min: $localize`Transcoding threads must be greater or equal to 0.`
   }
 }
 
 export const MAX_LIVE_DURATION_VALIDATOR: BuildFormValidator = {
-  VALIDATORS: [Validators.required, Validators.min(-1)],
+  VALIDATORS: [ Validators.required, Validators.min(-1) ],
   MESSAGES: {
-    'required': $localize`Max live duration is required.`,
-    'min': $localize`Max live duration should be greater or equal to -1.`
+    required: $localize`Max live duration is required.`,
+    min: $localize`Max live duration should be greater or equal to -1.`
   }
 }
 
 export const MAX_INSTANCE_LIVES_VALIDATOR: BuildFormValidator = {
-  VALIDATORS: [Validators.required, Validators.min(-1)],
+  VALIDATORS: [ Validators.required, Validators.min(-1) ],
   MESSAGES: {
-    'required': $localize`Max instance lives is required.`,
-    'min': $localize`Max instance lives should be greater or equal to -1.`
+    required: $localize`Max instance lives is required.`,
+    min: $localize`Max instance lives should be greater or equal to -1.`
   }
 }
 
 export const MAX_USER_LIVES_VALIDATOR: BuildFormValidator = {
-  VALIDATORS: [Validators.required, Validators.min(-1)],
+  VALIDATORS: [ Validators.required, Validators.min(-1) ],
+  MESSAGES: {
+    required: $localize`Max user lives is required.`,
+    min: $localize`Max user lives should be greater or equal to -1.`
+  }
+}
+
+export const MAX_VIDEO_CHANNELS_PER_USER_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
   MESSAGES: {
-    'required': $localize`Max user lives is required.`,
-    'min': $localize`Max user lives should be greater or equal to -1.`
+    required: $localize`Max video channels per user is required.`,
+    min: $localize`Max video channels per user must be greater or equal to 1.`,
+    pattern: $localize`Max video channels per user must be a number.`
   }
 }
 
 export const CONCURRENCY_VALIDATOR: BuildFormValidator = {
-  VALIDATORS: [Validators.required, Validators.min(1)],
+  VALIDATORS: [ Validators.required, Validators.min(1) ],
   MESSAGES: {
-    'required': $localize`Concurrency is required.`,
-    'min': $localize`Concurrency should be greater or equal to 1.`
+    required: $localize`Concurrency is required.`,
+    min: $localize`Concurrency should be greater or equal to 1.`
   }
 }
 
 export const INDEX_URL_VALIDATOR: BuildFormValidator = {
-  VALIDATORS: [Validators.pattern(/^https:\/\//)],
+  VALIDATORS: [ Validators.pattern(/^https:\/\//) ],
   MESSAGES: {
-    'pattern': $localize`Index URL should be a URL`
+    pattern: $localize`Index URL should be a URL`
   }
 }
 
 export const SEARCH_INDEX_URL_VALIDATOR: BuildFormValidator = {
-  VALIDATORS: [Validators.pattern(/^https?:\/\//)],
+  VALIDATORS: [ Validators.pattern(/^https?:\/\//) ],
   MESSAGES: {
-    'pattern': $localize`Search index URL should be a URL`
+    pattern: $localize`Search index URL should be a URL`
   }
 }