-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a validation fallback directive
I chose to design it the following way - name it valFallback instead of valDefaultError, to avoid confusion with the default-validation-errors directive - expose the label, the error, and the type of the error to the fallback template - if the display mode is ALL, then all the errors are displayed. So if two or more errors are not handled by specific error directives, the fallback template is displayed several time. I expect this to rarely happen. But it allows using the error type as an i18n key to display all the errors the same way. If the fallback is used to handle forgotten error types, then it will at least make it clear that several types have been forgotten. - if the display mode is ONE, then the fallback template is only displayed once, if no error is handled by a specific error directive. Since there might be several errors handled by the fallback, the order is undefined, and we thus have no guarantee over which of the error will be displayed. fix #264
- Loading branch information
Showing
12 changed files
with
218 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 19 additions & 8 deletions
27
projects/ngx-valdemort/src/lib/validation-errors.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
<ng-container *ngIf="shouldDisplayErrors"> | ||
<div [class]="errorClasses" *ngFor="let errorDirective of errorDirectivesToDisplay"> | ||
<ng-container | ||
*ngTemplateOutlet="errorDirective!.templateRef; context: { | ||
$implicit: label, | ||
error: actualControl.errors![errorDirective.type] | ||
}" | ||
></ng-container> | ||
</div> | ||
<ng-container *ngIf="errorsToDisplay as e"> | ||
<div [class]="errorClasses" *ngFor="let errorDirective of e.errors"> | ||
<ng-container | ||
*ngTemplateOutlet="errorDirective!.templateRef; context: { | ||
$implicit: label, | ||
error: actualControl!.errors![errorDirective.type] | ||
}" | ||
></ng-container> | ||
</div> | ||
<div [class]="errorClasses" *ngFor="let error of e.fallbackErrors"> | ||
<ng-container | ||
*ngTemplateOutlet="e.fallback!.templateRef; context: { | ||
$implicit: label, | ||
type: error.type, | ||
error: error.value | ||
}" | ||
></ng-container> | ||
</div> | ||
</ng-container> | ||
</ng-container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.