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-error-msg

v1.0.0

Published

A library to map form errors to error messages and display them.

Readme

NgxErrorMsg

pipeline status Coverage Reliability Rating Security Rating Vulnerabilities

The error message mapping library for Angular.

Live Demo

Features

✅ Dynamic display of error message
✅ Reactive and template driven forms support
✅ I18n libraries support
✅ SSR support
✅ Standalone support
✅ Zoneless change detection support

Dependencies

|Angular | |:-------| |15 to 19|

Installation

npm install ngx-error-msg --save

Usage

Standalone directive

The *ngxErrorMsg directive can be used without configuring providers globally. In such a case, the ngxErrorMsgMappings input is required.

<input
    name="title"
    [(ngModel)]="title"
    required
    minlength="5"
    maxlength="10"
    #titleControl="ngModel" />
<span *ngxErrorMsg="titleControl.errors; mappings: errorMappings; let mappedErrors">
    {{ mappedErrors.message }}
    <!-- Or use {{ mappedErrors.messages }} to access each mapped error message separately. -->
</span>
@Component({
    // ...
    imports: [FormsModule, NgxErrorMsgDirective],
    standalone: true,
})
export class AppComponent {
    title = 'example';
    errorMappings: ErrorMessageMappings = {
        required: 'Title is required',
        minlength: error => `Title min length is ${error.requiredLength}`,
        maxlength: error => `Title max length is ${error.requiredLength}`,
    };
}

Provided configuration

Mappings and configuration can be defined at any level using providers. For example, all commonly used error messages and configuration can be defined at the root level and extended or overridden in child providers or on a directive level.

provideNgxErrorMsg(
    withMappings({
        required: (_, ctx) => `${ctx.field ?? 'This field'} is required.`,
        minlength: error => `Minimum length is ${error.requiredLength}.`,
    }),
    withConfig({ errorsLimit: 1 }),
)

Translated messages

NgxErrorMsg library supports mappings to Observable making it possible to use i18n error messages.

provideNgxErrorMsg(
    withMappings(() => {
        const translate = inject(TranslateService); // Or use any other i18n library.

        return {
            required: () => translate.get('ERRORS.REQUIRED'),
            minlength: error =>
                translate.get('ERRORS.MIN_LENGTH', { value: error.requiredLength }),
        };
    }),
)

Error messages prioritization

By default the order of mapped error messages is based on the order in the mappings object (e.g. provided by withMappings). This behavior can be overridden by using one of predefined prioritizers or defining a custom one.

withConfig({
    messagesPrioritizer: (errors, mappings) => {
        const errorsOrder = ['required', 'minlength', 'email'];

        return (errA, errB) => {
            return errorsOrder.indexOf(errA) - errorsOrder.indexOf(errB);
        };
    },
})

NOTE: The messagesPrioritizer function is not executed in an injection context. To use injected values, a factory configuration provider must be used.

withConfig(() => {
    const service = inject(MyService); 
    return {};
})