ng-smart-form-error-mapper
v1.1.0
Published
> Centralized, plug-and-play Angular form validation messages with i18n support. > Zero boilerplate. One line per input.
Readme
ng-smart-form-error-mapper
Centralized, plug-and-play Angular form validation messages with i18n support. Zero boilerplate. One line per input.
The Problem
<!-- ❌ Before — repeated in every template -->
<div *ngIf="f.get('email')?.errors?.['required'] && f.get('email')?.touched">
Email is required.
</div>The Solution
<!-- ✅ After — one attribute, done -->
<input formControlName="email" appError />Installation
npm install ng-smart-form-error-mapperQuick Start
// app.config.ts
provideFormErrors({
required: () => 'This field is required.',
email: () => 'Enter a valid email address.',
minlength: (p) => `Minimum ${p.requiredLength} characters.`,
})<!-- template -->
<input formControlName="email" appError />
<input formControlName="bio" appError [errorOnDirty]="true" />
<form-error [control]="form.get('password')" [showAll]="true" />Demo
Try it: Demo
See README and CHANGELOG for full docs.
License
MIT
