From 7ed1edbbe4ffbef28093e4f5630751cb652814e4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 17 Aug 2020 11:47:04 +0200 Subject: We don't need services anymore for validators --- .../shared/form-validators/instance-validators.ts | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 client/src/app/shared/form-validators/instance-validators.ts (limited to 'client/src/app/shared/form-validators/instance-validators.ts') diff --git a/client/src/app/shared/form-validators/instance-validators.ts b/client/src/app/shared/form-validators/instance-validators.ts new file mode 100644 index 000000000..a72e28ba0 --- /dev/null +++ b/client/src/app/shared/form-validators/instance-validators.ts @@ -0,0 +1,49 @@ +import { Validators } from '@angular/forms' +import { BuildFormValidator } from './form-validator.model' + +export const FROM_EMAIL_VALIDATOR: BuildFormValidator = { + VALIDATORS: [Validators.required, Validators.email], + MESSAGES: { + 'required': $localize`Email is required.`, + 'email': $localize`Email must be valid.` + } +} + +export const FROM_NAME_VALIDATOR: BuildFormValidator = { + VALIDATORS: [ + Validators.required, + Validators.minLength(1), + Validators.maxLength(120) + ], + MESSAGES: { + 'required': $localize`Your name is required.`, + 'minlength': $localize`Your name must be at least 1 character long.`, + 'maxlength': $localize`Your name cannot be more than 120 characters long.` + } +} + +export const SUBJECT_VALIDATOR: BuildFormValidator = { + VALIDATORS: [ + Validators.required, + Validators.minLength(1), + Validators.maxLength(120) + ], + MESSAGES: { + 'required': $localize`A subject is required.`, + 'minlength': $localize`The subject must be at least 1 character long.`, + 'maxlength': $localize`The subject cannot be more than 120 characters long.` + } +} + +export const BODY_VALIDATOR: BuildFormValidator = { + VALIDATORS: [ + Validators.required, + Validators.minLength(3), + Validators.maxLength(5000) + ], + MESSAGES: { + 'required': $localize`A message is required.`, + 'minlength': $localize`The message must be at least 3 characters long.`, + 'maxlength': $localize`The message cannot be more than 5000 characters long.` + } +} -- cgit v1.2.3