Skip to content

Dzivo/angular-oib-validator

Repository files navigation

angular oib validator

Build Status codecov npm version devDependency Status GitHub issues GitHub stars GitHub license

Demo

https://dzivo.github.io/angular-oib-validator/

Table of contents

About

Angular OIB validator

Installation

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 { OibValidator } from 'angular-oib-validator';

@Component({
  selector: 'oib-demo-app',
  template: `
  <div class="container">
    <form [formGroup]="form">
        <h1>Simple Example Validator</h1>
        <input type="text" formControlName="oib-simple">
        <div *ngIf="form.controls.oib-simple.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-simple': [null, [OibValidator.check]]
    });
  }
}

You may also find it useful to view the demo source.

Usage without a module bundler

<script src="node_modules/angular-oib-validator/bundles/angular-oib-validator.umd.js"></script>
<script>
    // everything is exported angularOibValidator namespace
</script>

Documentation

All documentation is auto-generated from the source via compodoc and can be viewed here: https://dzivo.github.io/angular-oib-validator/docs/

Development

Prepare your environment

  • Install Node.js and NPM
  • Install local dev dependencies: npm install while current directory is this repo

Development server

Run npm start to start a development server on port 8000 with auto reload + tests.

Testing

Run npm test to run tests once or npm run test:watch to continually run tests.

Release

  • Bump the version in package.json (once the module hits 1.0 this will become automatic)
npm run release

License

MIT

About

Croatian OIB (Osobni identifikacijski broj) validator

Resources

License

Stars

Watchers

Forks

Packages

No packages published