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

ngl-form-validator

v0.0.10

Published

That helper. Help to show errors messages. That library listen the changes in reactive controls. And it can be used in some html elements as: inputs, datetime picker, select, autocompletes, text area, etc.

Downloads

27

Readme

NglFormValidator

That helper. Help to show errors messages. That library listen the changes in reactive controls. And it can be used in some html elements as: inputs, datetime picker, select, autocompletes, text area, etc.

That library help to development process detect the changes in one html element and then show errors when that is detected.

GitHub

https://github.com/leninsvg/ngl/tree/main/projects/ngl-form-validator

Demo

https://stackblitz.com/edit/angular-ivy-bbcife?file=src/app/app.component.ts

Import

Import NglFormValidatorModule

 imports: [
    NglFormValidatorModule // Import this module
 ],

directive nglFormValidator

That helper has predefined error messages but that can be override if the user need.

Properties

formControl

Use as reference to on form control

formControlName

Use as reference to on form control in on group

inputReference

On that part make reference with the HTML input for make that is necessary to pass the input

customErrors

Array in that you can use a custom error message. If don't like to use the predefined messages. For override the error take in consideration the error name. For example for Validators.minLength(10) the error is minlength.

Settings

by default the library has default error messages but that can override and inject our messages

Preserve default error messages

@NgModule({
  imports: [
    ...
    NglFormValidatorModule,
  ],
})
export class AppModule {

Override the error configuration

Override error messages.

example:

const settings: FormValidatorSettings = {
  errorMessages: [{error: 'min', message: 'minimo generico'}], // Override the error min as custom message
  defaultErrorMessage: 'xxxxx' // If don't have defined messages for all errors that is a default messages
}
@NgModule({
  imports: [
    ...
    NglFormValidatorModule.forRoot(settings),
  ],
})
export class AppModule {

Usages

That library works with reactive forms.

form control

That directive create a binding between a reactive form control and html element the error messages can be in a div, label, mat-error, ...etc.

  <input  [formControl]="this.control" type="text" #txtControl>
  <div nglFormValidator [formControl]="control" [inputReference]="txtControl"></div>
  <label nglFormValidator [formControl]="control" [inputReference]="txtControl" [customErrors]="[{error: 'required', message: 'Campo Requerido'}]"></label>
  <button (click)="this.control.updateValueAndValidity()">SetControlValidators</button>

form group

That directive can be work with form control name make a reference with the form group properties

<div [formGroup]="testForm">
  <input formControlName="name" type="text" #name>
  <div nglFormValidator formControlName="name" [inputReference]="name"></div>
  <input formControlName="age" type="text" #age>
  <div nglFormValidator formControlName="age" [inputReference]="age"></div>
</div>
<button (click)="this.validateTestForm()">SetGroupValidators</button>

global validator

That functionality is exposed in one service and their functionality is validate all fields on one formGroup, formArray. That works with recursion

import in to the constructor

 private _nglFormValidatorService: NglFormValidatorService

call function for validate with form group as parameter

 this._nglFormValidatorService.validateAllFormFields(this.testForm);