https://dzivo.github.io/angular-oib-validator/
Angular OIB validator
Install through npm:
npm install --save angular-oib-validator
Then include in your apps module:
import { Component, NgModule } from '(angular/core';
import { AngularOibValidatorModule } from 'angular-oib-validator';
(NgModule({
imports: [
AngularOibValidatorModule.forRoot()
]
})
export class MyModule {}
Finally use in one of your apps components:
import { Component, OnInit } from '(angular/core';
import { FormGroup, FormControl, Validators, FormBuilder, FormArray, AbstractControl, ValidationErrors } from '(angular/forms';
import { checkOibValidator } from '../src/oib-validator';
(Component({
selector: 'oib-demo-app',
template: `
<div class="container">
<form [formGroup]="form">
<h1>Simple Example Validator</h1>
<input type="text" formControlName="oib">
<div *ngIf="form.controls.oib.errors?.validateOib">This doesn't appear to be a valid oib address.</div>
</form>
</div>
`
})
export class DemoComponent implements OnInit {
form: FormGroup;
constructor(
private _fb: FormBuilder) {
}
ngOnInit(): void {
this.form = this._fb.group({
'oib': [null, [Validators.required, checkOibValidator]]
});
}
}
You may also find it useful to view the demo source.
<script src="node_modules/angular-oib-validator/bundles/angular-oib-validator.umd.js"></script>
<script>
// everything is exported angularOibValidator namespace
</script>
All documentation is auto-generated from the source via compodoc and can be viewed here: https://dzivo.github.io/angular-oib-validator/docs/
npm install
while current directory is this repoRun npm start
to start a development server on port 8000 with auto reload + tests.
Run npm test
to run tests once or npm run test:watch
to continually run tests.
npm run release
MIT