aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/form-validators/video-channel-validators.ts
blob: ba502ed01069214a3b4518e02011ecd8631bbb04 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Validators } from '@angular/forms'
import { BuildFormValidator } from './form-validator.model'
import { USER_USERNAME_VALIDATOR } from './user-validators'

export const VIDEO_CHANNEL_NAME_VALIDATOR: BuildFormValidator = {
  // Use the same constraints than user usernmae
  VALIDATORS: USER_USERNAME_VALIDATOR.VALIDATORS,

  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`
  }
}