1 import { I18n } from '@ngx-translate/i18n-polyfill'
2 import { Validators } from '@angular/forms'
3 import { BuildFormValidator } from '@app/shared'
4 import { Injectable } from '@angular/core'
7 export class InstanceValidatorsService {
8 readonly FROM_EMAIL: BuildFormValidator
9 readonly FROM_NAME: BuildFormValidator
10 readonly SUBJECT: BuildFormValidator
11 readonly BODY: BuildFormValidator
13 constructor (private i18n: I18n) {
16 VALIDATORS: [ Validators.required, Validators.email ],
18 'required': this.i18n('Email is required.'),
19 'email': this.i18n('Email must be valid.')
26 Validators.minLength(1),
27 Validators.maxLength(120)
30 'required': this.i18n('Your name is required.'),
31 'minlength': this.i18n('Your name must be at least 1 character long.'),
32 'maxlength': this.i18n('Your name cannot be more than 120 characters long.')
39 Validators.minLength(1),
40 Validators.maxLength(120)
43 'required': this.i18n('A subject is required.'),
44 'minlength': this.i18n('The subject must be at least 1 character long.'),
45 'maxlength': this.i18n('The subject cannot be more than 120 characters long.')
52 Validators.minLength(3),
53 Validators.maxLength(5000)
56 'required': this.i18n('A message is required.'),
57 'minlength': this.i18n('The message must be at least 3 characters long.'),
58 'maxlength': this.i18n('The message cannot be more than 5000 characters long.')