Skip to content

tomi77/ngx-pl-validators

Repository files navigation

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>