@stumpam/ngx-cz-id

Angular input for czech id (Rodné číslo) with validation.

Usage no npm install needed!

<script type="module">
  import stumpamNgxCzId from 'https://cdn.skypack.dev/@stumpam/ngx-cz-id';
</script>

README

NgxCzId

Angular input for czech id (Rodné číslo) with validation.

Quick Start

  1. Import NgxCzIdModule to your project.
import { NgxCzIdModule } from '@stumpam/ngx-cz-id';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, NgxCzIdModule, ReactiveFormsModule],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}
  1. Use in HTML template
  • add attributes min or max to validate even age of person with current id
<input ngxCzId [formControl]="ctrl" [min]="18" [max]="25" [options]="options" [exception]="exception">

Exception accepts regexp which can bypass validation of ID (rodné číslo) in cases where is needed invalid ID (010101/9999). It still validates min/max ages.

  1. Optional options to emit only valid cz id value
options: {
  emitInvalid: false;
  // emits all typed characters not just valid / invalid complete id
  emitAll: boolean;
}

Automatically emits invalidCzId when length of string is valid but number is not valid id.

Works with formly

and use it in the template

<input ngxCzId [formControl]="formControl" [options]="to.czIdOptions>