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 }; +}