ngx-form-validator
v0.0.2
Published
A library for form validator specifically for Angular 2+ Usage for Reactive Forms
Maintainers
Readme
NgxFormValidator
A library for form validator specifically for Angular 2+ Usage for Reactive Forms
| |
|
|
--- | --- | --- | --- | --- |
Latest ✔ | Latest ✔ | 10+ ✔ | Latest ✔ | Latest ✔ |
Installation
ngx-form-validator is available via npm and yarn
Using npm:
$ npm install ngx-form-validator --saveUsing yarn:
$ yarn add ngx-form-validatorUsage
Import NgxFormValidatorModule in your module(YourModule):
// Import library module
import { NgxFormValidatorModule } from 'ngx-form-validator';
@NgModule({
imports: [
// ...
NgxFormValidatorModule
]
})
export class YourModule { }Now use in your template - simple variant
<ngx-form-validator [control]="{componentForm}.controls.{name}"></ngx-form-validator>or if control appears after dom render
<ngx-form-validator *ngIf="{componentForm}.controls.{name}" [control]="{componentForm}.controls.{name}"></ngx-form-validator>- [control]: Your Control - (where {componentForm} - your Reactive Form Name; {name} - your Control Name)
- [propName]: Your Control Name (type: String) (Used for Error pattern like "Enter a valid {propName}")
Cover these cases: 'required', 'maxlength', 'minlength', 'email', 'pattern'.
