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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-validation-handling

v4.0.6

Published

ngx-validation-handling, customizable, dynamic validation messages for angular forms.

Downloads

291

Readme

Welcome to ngx-validation-handling👋

ngx-validation-handling is an Angular library that provides customizable, dynamic validation messages for both reactive and template-driven forms.

✨Demo

See Demo page

Features

  • 🛠 Customizable Validation Messages: Tailor the validation messages to suit your application's needs.
  • 🔄 Dynamic Error Message Retrieval: Automatically fetch and display error messages.
  • 📋 Easy Integration with Reactive Forms: Seamlessly integrate with Angular's - - reactive forms.
  • 📝 Template-Driven Form Support: Supports template-driven forms for flexible validation handling.
  • 🌐 Localization and Internationalization (i18n): Easily localize validation messages for different languages.
  • 🎨 Styling and Customization: Style the validation messages to match your application's look and feel.
  • ⏲ Debounced Error Display: Avoid flashing error messages with debounced display.
  • 🔗 Integration with Third-Party Libraries: Compatible with other Angular libraries.
  • ⏳ Async Validator Support: Handle asynchronous validators effectively.
  • ⚙ Configurable Error Display Strategies: Customize how and when error messages are displayed.
  • 🛡 Custom Validation Error Handlers: Define your own handlers for validation errors.
  • 📝 Form-Wide Error Summary: Provide a summary of errors for the entire form.

🚀Getting started

Usage with reactive form

Step 1: install ngx-validation-handling

NPM

 npm i ngx-validation-handling --save

YARN

 yarn add ngx-validation-handling 

Step 2: Import the "NgxValidationHandlingModule"

import { NgxValidationHandlingModule } from 'ngx-validation-handling';
@NgModule({
  declarations: [AppComponent],
  imports: [NgxValidationHandlingModule],
  bootstrap: [AppComponent]
})
export class AppModule {}

Step 3: Import the "NgxValidationHandlingService" in your component

import { Component } from '@angular/core';
import {NgxValidationHandlingService} from 'ngx-validation-handling';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  constructor(
  ...
  private ngxValidationHandlingService:NgxValidationHandlingService
  ){}

}

Step 4: Use "NgxValidationHandlingService" to send your form and your validation messsages example:

  ngOnInit(): void {
    // After intit your form
    this.ngxValidationHandlingService.setValidationHandling(this.form,
      {
        required: 'This field is required',
        minlength: 'Minimum length should be 3',
        maxlength: 'Maximum length should be 10'
      }
    );
  }

Step 5: In template use "ngx-validation-handling" component and send your from control name

<ngx-validation-handling controlName="fName"></ngx-validation-handling>

Usage with template-driven from

import { Component } from '@angular/core';
import {NgxValidationHandlingService} from 'ngx-validation-handling';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
@ViewChild('form') form!:NgForm;

constructor(
 private ngxValidationHandlingService:NgxValidationHandlingService
 ){}

 ngAfterViewInit(): void {
    this.ngxValidationHandlingService.setValidationHandling(this.form,
      {
        required: 'This field is required',
        minlength: 'Minimum length should be 3',
        maxlength: 'Maximum length should be 10'
      }
    );

In your template use "ngx-validation-handling" component and send your from control name

<ngx-validation-handling controlName="fName"></ngx-validation-handling>

API Reference

@Inputs

| Input | Type | Description | | :-------- | :------- | :------------------------- | | controlName | string | Required. Takes your input formControlName | | fieldName | string | The name of your field | | className | string | Add your custom className | | style | {} | Add your custom styles |

@Methods

| Input | Type | Description | | :-------- | :------- | :------------------------- | | customErrorHandler | ValidationErrorHandler | Method to add more customized validation errors in your control |

👤 Authors

@Mustafa-Seif

🔗 Links

portfolio linkedin

📝License

MIT

🤝 Support

For support or any feedback, email [email protected]