feat: add form errors dictionaries
This commit is contained in:
18
src/app/errors-dictionaries/name-and-company-field.ts
Normal file
18
src/app/errors-dictionaries/name-and-company-field.ts
Normal 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 };
|
||||
}
|
||||
}
|
||||
14
src/app/errors-dictionaries/phone-field.ts
Normal file
14
src/app/errors-dictionaries/phone-field.ts
Normal 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 };
|
||||
}
|
||||
}
|
||||
3
src/app/interfaces/dictionary.interface.ts
Normal file
3
src/app/interfaces/dictionary.interface.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface Dictionary {
|
||||
getDictionary(): { [key: string]: string };
|
||||
}
|
||||
Reference in New Issue
Block a user