ValidationMessageModule gives you possibility to localize form validators and it automatically puts localized validator error message to markup (if there is one). Fully compatable with angular reactive form validators.
Before (dirty *ngIf markup):
<input id="name" name="name" class="form-control"
required minlength="4" appForbiddenName="bob"
[(ngModel)]="hero.name" #name="ngModel" >
<div *ngIf="name.errors.minlength">
Name must be at least 4 characters long.
</div>
After (clean markup with auto inserting error messages):
<input validationMessage name="email" type="email" class="form-control" formControlName="email" [(ngModel)]="model.email" />
-
npm install angular-validation-message
- Import ValidationMessageModule to module where you expect to enable error message to form fields
- Set validationMessage directive to any form fields
Bridge for "angular-validation-message" for translate error messages via i18next.
Requirements:
-
npm install i18next angular-i18next
- import I18NextValidationMessageModule insteand of ValidationMessageModule
You can implement your own provider. Check source code of I18NextValidationMessageModule as example
Since v2 angular-validation-message includes providers