Skip to content

Commit 3b5a029

Browse files
committed
fix: fallback strategy of error messages
1 parent 6f12949 commit 3b5a029

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{
22
"name": "@xtream/ngx-validation-errors",
3+
"author": "Luca Micieli <[email protected]>",
34
"version": "0.0.1",
5+
"repository": {
6+
"url": "https://github.com/xtreamsrl/ngx-validation-errors"
7+
},
48
"peerDependencies": {
59
"@angular/common": "^7.2.0",
610
"@angular/core": "^7.2.0",
11+
"@angular/forms": "^7.2.0",
712
"@ngx-translate/core": "^11.0.1"
813
}
914
}

projects/xtream/ngx-validation-errors/src/lib/form-field-container.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ export class FormFieldContainerComponent implements AfterViewInit {
8686
if (hasError && this.input && this.input.nativeElement) {
8787
this.messages = Object.keys(this.formControl.errors).map(error => {
8888
const fieldName = this.formControl.name;
89-
const errorKey = `ERRORS.${toScreamingSnakeCase(fieldName)}.${toScreamingSnakeCase(error)}`;
89+
const errorKey = `${toScreamingSnakeCase(fieldName)}.ERRORS.${toScreamingSnakeCase(error)}`;
9090
if (this.translateService.instant(`${this.validationContext}.${errorKey}`) === `${this.validationContext}.${errorKey}`) {
91-
return `${this.validationErrorsConfig.defaultContext}.${errorKey}`;
91+
return `${this.validationErrorsConfig.defaultContext}.ERRORS.${toScreamingSnakeCase(error)}`;
9292
} else {
9393
return `${this.validationContext}.${errorKey}`;
9494
}

projects/xtream/ngx-validation-errors/src/lib/validation-context.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class ValidationContextComponent implements AfterContentInit {
1111
@ContentChildren(FormFieldContainerComponent, {descendants: true}) validators: QueryList<FormFieldContainerComponent>;
1212

1313
// tslint:disable:no-input-rename
14-
@Input('validationContext') validationContext: string;
14+
@Input() validationContext: string;
1515
@Input() innerValidationError: boolean;
1616

1717
ngAfterContentInit(): void {

0 commit comments

Comments
 (0)