]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/forms/form-validators/video-channel-validators.service.ts
Remove dashes from actor names
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / forms / form-validators / video-channel-validators.service.ts
1 import { I18n } from '@ngx-translate/i18n-polyfill'
2 import { Validators } from '@angular/forms'
3 import { Injectable } from '@angular/core'
4 import { BuildFormValidator } from '@app/shared'
5
6 @Injectable()
7 export class VideoChannelValidatorsService {
8 readonly VIDEO_CHANNEL_NAME: BuildFormValidator
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) {
14 this.VIDEO_CHANNEL_NAME = {
15 VALIDATORS: [
16 Validators.required,
17 Validators.minLength(1),
18 Validators.maxLength(50),
19 Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
20 ],
21 MESSAGES: {
22 'required': this.i18n('Name is required.'),
23 'minlength': this.i18n('Name must be at least 1 character long.'),
24 'maxlength': this.i18n('Name cannot be more than 50 characters long.'),
25 'pattern': this.i18n('Name should be lowercase alphanumeric; underscores are allowed.')
26 }
27 }
28
29 this.VIDEO_CHANNEL_DISPLAY_NAME = {
30 VALIDATORS: [
31 Validators.required,
32 Validators.minLength(1),
33 Validators.maxLength(50)
34 ],
35 MESSAGES: {
36 'required': i18n('Display name is required.'),
37 'minlength': i18n('Display name must be at least 1 character long.'),
38 'maxlength': i18n('Display name cannot be more than 50 characters long.')
39 }
40 }
41
42 this.VIDEO_CHANNEL_DESCRIPTION = {
43 VALIDATORS: [
44 Validators.minLength(3),
45 Validators.maxLength(1000)
46 ],
47 MESSAGES: {
48 'minlength': i18n('Description must be at least 3 characters long.'),
49 'maxlength': i18n('Description cannot be more than 1000 characters long.')
50 }
51 }
52
53 this.VIDEO_CHANNEL_SUPPORT = {
54 VALIDATORS: [
55 Validators.minLength(3),
56 Validators.maxLength(1000)
57 ],
58 MESSAGES: {
59 'minlength': i18n('Support text must be at least 3 characters long.'),
60 'maxlength': i18n('Support text cannot be more than 1000 characters long.')
61 }
62 }
63 }
64 }