
Security News
The Next Open Source Security Race: Triage at Machine Speed
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.
@ngspot/ngx-errors
Advanced tools
Reactive forms validation for pros
I solely missed ng-messages directive from AngularJs, so I created this one to use in Angular 2+.
In contrast to the one from AngularJs, this one requires you to pass the control name to the directive, instead of its errors.
This allowed me to hook in to the status of control, like its dirty state, and display validation messages according to that status.
A nice side effect of that decision is less boilerplate code.
npm install @ngspot/ngx-errors
yarn add @ngspot/ngx-errors
Import library into your application module:
import { NgxErrorsModule } from '@ngspot/ngx-errors'; // <-- import the module
@NgModule({
imports: [
NgxErrorsModule, // <-- include it in your app module
],
})
export class MyAppModule {}
@Component({
selector: 'my-component',
template: `
<form [formGroup]="myForm">
<input formControlName="email" type="email" />
<div ngxErrors="email">
<div ngxError="required">Email is required</div>
</div>
</form>
`,
})
export class MyComponent implements OnInit {
myForm: FormGroup;
constructor(private fb: FormBuilder) {
this.myForm = this.fb.group({
email: ['', Validators.required],
});
}
}
@Component({
selector: 'my-component',
template: `
<input [formControl]="email" placeholder="Email" type="email" />
<div [ngxErrors]="email">
<div ngxError="required">Email is required</div>
</div>
`,
})
export class MyComponent implements OnInit {
email = new FormControl('', Validators.required);
}
You configure when to show messages for your whole module by using .configure() method:
@NgModule({
imports: [
NgxErrorsModule.configure({ ... }) // <- provide configuration here
],
})
export class MyAppModule {}
Alternatively, use dependency injection to provide configuration at a component level:
import { ErrorsConfiguration } from '@ngspot/ngx-errors';
const myConfig = { ... }; // <- specify your config
@Component({
...
providers: [
{ provide: ErrorsConfiguration, useValue: myConfig }
]
})
export class MyComponent { }
Here's configuration object interface:
interface IErrorsConfiguration {
/**
* Configure errors to show only when the corresponding input is dirty.
*
* Default is `true`.
*/
showErrorsOnlyIfInputDirty?: boolean;
/**
* Configure errors to show only when form is submitted.
* Upon form submission shows errors even if `showErrorsOnlyIfInputDirty = true`
* and some of the inputs aren't dirty.
* Takes effect only when ngxErrors directive is a child of a form.
*
* Default is `false`.
*/
showErrorsWhenFormSubmitted?: boolean;
}
Just include something similar to the following in your global css file:
[ngxerrors] {
color: red;
}
build:lib - Builds the librarytest:lib - Runs teststest:lib:headless - Runs tests in headless mode with Chromerelease - Releases a new version. This will bump the library's version, and update the CHANGE_LOG file based on the commit messagerelease:first - Creates the first releasecommit - Creates a new commit message based on Angular commit messgae conventioncontributors:add - Adds a new contributor to the README fileMIT © Dmitry Efimenko
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
Unknown package
We found that @ngspot/ngx-errors demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.

Research
/Security News
Malicious dYdX client packages were published to npm and PyPI after a maintainer compromise, enabling wallet credential theft and remote code execution.

Security News
gem.coop is testing registry-level dependency cooldowns to limit exposure during the brief window when malicious gems are most likely to spread.