feat: add form errors dictionaries

This commit is contained in:
2025-12-11 21:21:00 -03:00
parent bda4cb9136
commit 65fb14aea5
3 changed files with 35 additions and 0 deletions

View File

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

View File

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

View File

@@ -0,0 +1,3 @@
export interface Dictionary {
getDictionary(): { [key: string]: string };
}