]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/form-validators/user-validators.ts
Fix lint
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / form-validators / user-validators.ts
index 976c97b872f981c6d71a0f010be66000e5a5e06f..ed6e0582eaad8b4078742c208ca9a8ebc607de22 100644 (file)
@@ -11,10 +11,10 @@ export const USER_USERNAME_VALIDATOR: BuildFormValidator = {
     Validators.pattern(new RegExp(`^${USER_USERNAME_REGEX_CHARACTERS}*$`))
   ],
   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.`
+    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.`
   }
 }
 
@@ -26,18 +26,18 @@ export const USER_CHANNEL_NAME_VALIDATOR: BuildFormValidator = {
     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, and can contain only alphanumeric characters, dots and underscores.`
+    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, and can contain only alphanumeric characters, dots and underscores.`
   }
 }
 
 export const USER_EMAIL_VALIDATOR: BuildFormValidator = {
   VALIDATORS: [ Validators.required, Validators.email ],
   MESSAGES: {
-    'required': $localize`Email is required.`,
-    'email': $localize`Email must be valid.`
+    required: $localize`Email is required.`,
+    email: $localize`Email must be valid.`
   }
 }
 
@@ -47,8 +47,8 @@ export const USER_HANDLE_VALIDATOR: BuildFormValidator = {
     Validators.pattern(/@.+/)
   ],
   MESSAGES: {
-    'required': $localize`Handle is required.`,
-    'pattern': $localize`Handle must be valid (eg. chocobozzz@example.com).`
+    required: $localize`Handle is required.`,
+    pattern: $localize`Handle must be valid (eg. chocobozzz@example.com).`
   }
 }
 
@@ -57,20 +57,29 @@ export const USER_EXISTING_PASSWORD_VALIDATOR: BuildFormValidator = {
     Validators.required
   ],
   MESSAGES: {
-    'required': $localize`Password is required.`
+    required: $localize`Password is required.`
   }
 }
 
-export const USER_PASSWORD_VALIDATOR: BuildFormValidator = {
+export const USER_OTP_TOKEN_VALIDATOR: BuildFormValidator = {
+  VALIDATORS: [
+    Validators.required
+  ],
+  MESSAGES: {
+    required: $localize`OTP token is required.`
+  }
+}
+
+export const USER_PASSWORD_VALIDATOR = {
   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.`
+    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.`
   }
 }
 
@@ -80,37 +89,37 @@ export const USER_PASSWORD_OPTIONAL_VALIDATOR: BuildFormValidator = {
     Validators.maxLength(255)
   ],
   MESSAGES: {
-    'minlength': $localize`Password must be at least 6 characters long.`,
-    'maxlength': $localize`Password cannot be more than 255 characters long.`
+    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.`
+    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.`
+    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.`
+    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.`
+    required: $localize`User role is required.`
   }
 }
 
@@ -122,15 +131,8 @@ export const USER_DESCRIPTION_VALIDATOR: BuildFormValidator = {
     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.`
+    minlength: $localize`Description must be at least 3 characters long.`,
+    maxlength: $localize`Description cannot be more than 1000 characters long.`
   }
 }
 
@@ -140,8 +142,8 @@ export const USER_BAN_REASON_VALIDATOR: BuildFormValidator = {
     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.`
+    minlength: $localize`Ban reason must be at least 3 characters long.`,
+    maxlength: $localize`Ban reason cannot be more than 250 characters long.`
   }
 }
 
@@ -152,9 +154,9 @@ function buildDisplayNameValidator (required: boolean) {
       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.`
+      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.`
     }
   }