]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/forms/form-validators/video-playlist-validators.service.ts
Add/update/delete/list my playlists
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / forms / form-validators / video-playlist-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 VideoPlaylistValidatorsService {
8 readonly VIDEO_PLAYLIST_DISPLAY_NAME: BuildFormValidator
9 readonly VIDEO_PLAYLIST_PRIVACY: BuildFormValidator
10 readonly VIDEO_PLAYLIST_DESCRIPTION: BuildFormValidator
11 readonly VIDEO_PLAYLIST_CHANNEL_ID: BuildFormValidator
12
13 constructor (private i18n: I18n) {
14 this.VIDEO_PLAYLIST_DISPLAY_NAME = {
15 VALIDATORS: [
16 Validators.required,
17 Validators.minLength(1),
18 Validators.maxLength(120)
19 ],
20 MESSAGES: {
21 'required': this.i18n('Display name is required.'),
22 'minlength': this.i18n('Display name must be at least 1 character long.'),
23 'maxlength': this.i18n('Display name cannot be more than 120 characters long.')
24 }
25 }
26
27 this.VIDEO_PLAYLIST_PRIVACY = {
28 VALIDATORS: [
29 Validators.required
30 ],
31 MESSAGES: {
32 'required': this.i18n('Privacy is required.')
33 }
34 }
35
36 this.VIDEO_PLAYLIST_DESCRIPTION = {
37 VALIDATORS: [
38 Validators.minLength(3),
39 Validators.maxLength(1000)
40 ],
41 MESSAGES: {
42 'minlength': i18n('Description must be at least 3 characters long.'),
43 'maxlength': i18n('Description cannot be more than 1000 characters long.')
44 }
45 }
46
47 this.VIDEO_PLAYLIST_CHANNEL_ID = {
48 VALIDATORS: [ ],
49 MESSAGES: { }
50 }
51 }
52 }