1.0.1 • Published 3 years ago

ngx-pl-validators v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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>