]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/forms/form-validators/video-channel-validators.service.ts
Feature/description support fields length 1000 (#1267)
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / forms / form-validators / video-channel-validators.service.ts
CommitLineData
e309822b
C
1import { I18n } from '@ngx-translate/i18n-polyfill'
2import { Validators } from '@angular/forms'
3import { Injectable } from '@angular/core'
4import { BuildFormValidator } from '@app/shared'
5
6@Injectable()
7export class VideoChannelValidatorsService {
8a19bee1 8 readonly VIDEO_CHANNEL_NAME: BuildFormValidator
e309822b
C
9 readonly VIDEO_CHANNEL_DISPLAY_NAME: BuildFormValidator
10 readonly VIDEO_CHANNEL_DESCRIPTION: BuildFormValidator
11 readonly VIDEO_CHANNEL_SUPPORT: BuildFormValidator
12
13 constructor (private i18n: I18n) {
8a19bee1
C
14 this.VIDEO_CHANNEL_NAME = {
15 VALIDATORS: [
16 Validators.required,
17 Validators.minLength(3),
18 Validators.maxLength(20),
19 Validators.pattern(/^[a-z0-9._]+$/)
20 ],
21 MESSAGES: {
22 'required': this.i18n('Name is required.'),
23 'minlength': this.i18n('Name must be at least 3 characters long.'),
24 'maxlength': this.i18n('Name cannot be more than 20 characters long.'),
25 'pattern': this.i18n('Name should be only lowercase alphanumeric characters.')
26 }
27 }
28
e309822b
C
29 this.VIDEO_CHANNEL_DISPLAY_NAME = {
30 VALIDATORS: [
31 Validators.required,
32 Validators.minLength(3),
33 Validators.maxLength(120)
34 ],
35 MESSAGES: {
36 'required': i18n('Display name is required.'),
37 'minlength': i18n('Display name must be at least 3 characters long.'),
38 'maxlength': i18n('Display name cannot be more than 120 characters long.')
39 }
40 }
41
42 this.VIDEO_CHANNEL_DESCRIPTION = {
43 VALIDATORS: [
44 Validators.minLength(3),
d23e6a1c 45 Validators.maxLength(1000)
e309822b
C
46 ],
47 MESSAGES: {
48 'minlength': i18n('Description must be at least 3 characters long.'),
d23e6a1c 49 'maxlength': i18n('Description cannot be more than 1000 characters long.')
e309822b
C
50 }
51 }
52
53 this.VIDEO_CHANNEL_SUPPORT = {
54 VALIDATORS: [
55 Validators.minLength(3),
d23e6a1c 56 Validators.maxLength(1000)
e309822b
C
57 ],
58 MESSAGES: {
59 'minlength': i18n('Support text must be at least 3 characters long.'),
d23e6a1c 60 'maxlength': i18n('Support text cannot be more than 1000 characters long.')
e309822b
C
61 }
62 }
63 }
64}