From 65fb14aea5fd1c037127ce82d514e189d3d0bb88 Mon Sep 17 00:00:00 2001 From: Gabriel De Los Rios Date: Thu, 11 Dec 2025 21:21:00 -0300 Subject: [PATCH] feat: add form errors dictionaries --- .../name-and-company-field.ts | 18 ++++++++++++++++++ src/app/errors-dictionaries/phone-field.ts | 14 ++++++++++++++ src/app/interfaces/dictionary.interface.ts | 3 +++ 3 files changed, 35 insertions(+) create mode 100644 src/app/errors-dictionaries/name-and-company-field.ts create mode 100644 src/app/errors-dictionaries/phone-field.ts create mode 100644 src/app/interfaces/dictionary.interface.ts diff --git a/src/app/errors-dictionaries/name-and-company-field.ts b/src/app/errors-dictionaries/name-and-company-field.ts new file mode 100644 index 0000000..3087467 --- /dev/null +++ b/src/app/errors-dictionaries/name-and-company-field.ts @@ -0,0 +1,18 @@ +import { inject } from '@angular/core'; +import { Dictionary } from '../interfaces/dictionary.interface'; +import { STRINGS_INJECTOR } from '../app.config'; + +export class NameAndCompanyFieldsErrorsDictionary implements Dictionary { + private readonly strings = inject(STRINGS_INJECTOR); + private readonly maxlen: string; + private readonly required = this.strings.errorMessageRequired; + + constructor() { + this.maxlen = this.strings.errorMessageMaxLength(120); + } + + getDictionary(): { [key: string]: string } { + const { maxlen, required } = this; + return { maxlen, required }; + } +} diff --git a/src/app/errors-dictionaries/phone-field.ts b/src/app/errors-dictionaries/phone-field.ts new file mode 100644 index 0000000..0bddeea --- /dev/null +++ b/src/app/errors-dictionaries/phone-field.ts @@ -0,0 +1,14 @@ +import { inject } from '@angular/core'; +import { Dictionary } from '../interfaces/dictionary.interface'; +import { STRINGS_INJECTOR } from '../app.config'; + +export class PhoneFieldErroresDictionary implements Dictionary { + strings = inject(STRINGS_INJECTOR); + pattern = this.strings.errorMessagePhonePattern; + required = this.strings.errorMessageRequired; + + getDictionary(): { [key: string]: string } { + const { required, pattern } = this; + return { required, pattern }; + } +} diff --git a/src/app/interfaces/dictionary.interface.ts b/src/app/interfaces/dictionary.interface.ts new file mode 100644 index 0000000..de4b5b5 --- /dev/null +++ b/src/app/interfaces/dictionary.interface.ts @@ -0,0 +1,3 @@ +export interface Dictionary { + getDictionary(): { [key: string]: string }; +}