npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ngx-smart-errors

v0.0.2

Published

Modern, signal-based Angular form validation error handling. Zero boilerplate, global/local config, i18n, custom templates.

Downloads

172

Readme

ngx-smart-errors ✨

Production-ready Angular form error handling system.
Stop writing repetitive boilerplates for error validation and start using smart, reactive messages.


🎯 The Problem

Normally, to show errors in Angular, you write this for every input:

<!-- BEFORE: ❌ Repetitive, messy, and hard to maintain -->
@if (email.invalid && (email.touched || email.dirty)) {
  <div class="error">
    @if (email.errors?.['required']) {
      <span>Email is required</span>
    }
    @if (email.errors?.['email']) {
      <span>Invalid email format</span>
    }
  </div>
}

🚀 The Solution

With ngx-smart-errors, it's zero-boilerplate:

<!-- AFTER: ✅ Clean, dynamic, and configurable -->
<input [formControl]="email" ngxError />

<!-- OR using the component -->
<ngx-error [control]="email" />

⚙️ Features

  • Signals-based Reactivity: Fully reactive with Angular 17+ Signals.
  • Zero Configuration: Sensible defaults for all built-in validators.
  • Smart Triggers: Show errors on touched, dirty, or submit.
  • Global & Local Config: Override messages globally or locally.
  • Structural Directive: Append error UI automatically with a simple ngxError attribute.
  • i18n Ready: Native support for multi-language message maps.
  • Interpolation: Automatically Replace {requiredLength}, {min}, etc. from validator results.
  • Custom Templates: Complete control over Error UI via ng-template.

📦 Installation

npm install ngx-smart-errors

🛠️ Global Configuration

Provide global error messages in your app.config.ts:

import { provideSmartErrors } from 'ngx-smart-errors';

export const appConfig: ApplicationConfig = {
  providers: [
    provideSmartErrors({
      errorMessages: {
        required: 'This field is required',
        email: 'Please enter a valid email address',
        minlength: 'Minimum length is {requiredLength} characters',
      },
      defaultTrigger: 'touched', // or 'dirty', 'submit'
      defaultLanguage: 'en',
    })
  ]
};

📖 Usage Examples

1. Simple Directive Usage

Automatically appends the error component under the input.

<input formControlName="username" ngxError />

2. Manual Component Usage

<ngx-error [control]="form.controls.password" trigger="dirty" />

3. Custom Local Messages

<ngx-error 
  [control]="email" 
  [messages]="{ 
    required: 'We really need your email', 
    email: 'That does not look like an email' 
  }" 
/>

4. UI Customization with Templates

<ngx-error [control]="email">
  <ng-template let-error>
    <div class="alert alert-danger">
      <i class="icon-warning"></i> {{ error }}
    </div>
  </ng-template>
</ngx-error>

5. Using Signals (Modern Reactive API)

import { useError } from 'ngx-smart-errors';

@Component({ ... })
export class MyComponent {
  email = new FormControl('', [Validators.required]);
  // reactive signal that updates automatically
  emailError = useError(this.email); 
}

🌍 i18n support

provideSmartErrors({
  errorMessages: {
    required: {
      en: 'Required',
      tr: 'Zorunlu alan'
    }
  },
  defaultLanguage: 'en'
});

🧪 Roadmap

  • [ ] Support for Material Design (Auto-integration)
  • [ ] Auto-discovery of FormGroup submission state
  • [ ] Custom validation hint animations
  • [ ] Support for Async Validators

🎁 License

MIT.