aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-forms/form-validators/abuse-validators.service.ts
blob: 5f15963f326f6e79fe25aa0c11056621b745dee3 (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
import { I18n } from '@ngx-translate/i18n-polyfill'
import { Validators } from '@angular/forms'
import { Injectable } from '@angular/core'
import { BuildFormValidator } from './form-validator.service'

@Injectable()
export class AbuseValidatorsService {
  readonly ABUSE_REASON: BuildFormValidator
  readonly ABUSE_MODERATION_COMMENT: BuildFormValidator
  readonly ABUSE_MESSAGE: BuildFormValidator

  constructor (private i18n: I18n) {
    this.ABUSE_REASON = {
      VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
      MESSAGES: {
        'required': this.i18n('Report reason is required.'),
        'minlength': this.i18n('Report reason must be at least 2 characters long.'),
        'maxlength': this.i18n('Report reason cannot be more than 3000 characters long.')
      }
    }

    this.ABUSE_MODERATION_COMMENT = {
      VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
      MESSAGES: {
        'required': this.i18n('Moderation comment is required.'),
        'minlength': this.i18n('Moderation comment must be at least 2 characters long.'),
        'maxlength': this.i18n('Moderation comment cannot be more than 3000 characters long.')
      }
    }

    this.ABUSE_MESSAGE = {
      VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
      MESSAGES: {
        'required': this.i18n('Abuse message is required.'),
        'minlength': this.i18n('Abuse message must be at least 2 characters long.'),
        'maxlength': this.i18n('Abuse message cannot be more than 3000 characters long.')
      }
    }
  }
}