Skip to content

Latest commit

 

History

History
60 lines (42 loc) · 1.52 KB

README.md

File metadata and controls

60 lines (42 loc) · 1.52 KB

ngx-pl-validators

Build Status dependencies Status devDependencies Status peerDependencies Status

PESEL, NIP and REGON validators for Angular

Installation

npm install ngx-pl-validators

Usage (model driven)

Needs ReactiveFormsModule

PESEL

import { PLValidators } from 'ngx-pl-validators';

password: FormControl = new FormControl('', Validators.compose([
  PLValidators.peselValidator
]));

NIP

import { PLValidators } from 'ngx-pl-validators';

password: FormControl = new FormControl('', Validators.compose([
  PLValidators.nipValidator
]));

Usage (template driven)

Needs FormsModule and ValidatorsModule

PESEL

<form>
  <input type="text" [(ngModel)]="model.pesel" name="pesel" #formControl="ngModel" pesel />>
  <span *ngIf="formControl.hasError('pesel')">Invalid PESEL</span>
</form>

NIP

<form>
  <input type="text" [(ngModel)]="model.nip" name="nip" #formControl="ngModel" nip />>
  <span *ngIf="formControl.hasError('nip')">Invalid NIP</span>
</form>