ngx-form-validator
v0.0.2
Published
A library for form validator specifically for Angular 2+ Usage for Reactive Forms
Downloads
41
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 --save
Using yarn:
$ yarn add ngx-form-validator
Usage
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'.