]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/shared-forms/form-validators/abuse-validators.service.ts
Move form modules in the form shared module
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-forms / form-validators / abuse-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 './form-validator.service'
5
6 @Injectable()
7 export class AbuseValidatorsService {
8 readonly ABUSE_REASON: BuildFormValidator
9 readonly ABUSE_MODERATION_COMMENT: BuildFormValidator
10 readonly ABUSE_MESSAGE: BuildFormValidator
11
12 constructor (private i18n: I18n) {
13 this.ABUSE_REASON = {
14 VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
15 MESSAGES: {
16 'required': this.i18n('Report reason is required.'),
17 'minlength': this.i18n('Report reason must be at least 2 characters long.'),
18 'maxlength': this.i18n('Report reason cannot be more than 3000 characters long.')
19 }
20 }
21
22 this.ABUSE_MODERATION_COMMENT = {
23 VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
24 MESSAGES: {
25 'required': this.i18n('Moderation comment is required.'),
26 'minlength': this.i18n('Moderation comment must be at least 2 characters long.'),
27 'maxlength': this.i18n('Moderation comment cannot be more than 3000 characters long.')
28 }
29 }
30
31 this.ABUSE_MESSAGE = {
32 VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
33 MESSAGES: {
34 'required': this.i18n('Abuse message is required.'),
35 'minlength': this.i18n('Abuse message must be at least 2 characters long.'),
36 'maxlength': this.i18n('Abuse message cannot be more than 3000 characters long.')
37 }
38 }
39 }
40 }