Skip to content

Angular input for czech identification number (IČO) with validation.

License

Notifications You must be signed in to change notification settings

stumpam/ngx-cz-in

Repository files navigation

NgxCzIn

Angular input for czech identification number (IČO) with validation.

Quick Start

  1. Import NgxCzInDirective to your project (module) or component.
import { NgxCzInDirective } from '@stumpam/ngx-cz-in';

@Component({
  selector: 'ngx-cz-in-root',
  standalone: true,
  templateUrl: './app.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [NgxCzInDirective]
})
export class AppComponent
  1. Use in HTML template
  • add attributes min or max to validate even age of person with current id
<input ngxCzIn [formControl]="ctrl" [options]="options">
  1. Optional options to emit only valid cz id value
options: {
  emitInvalid?: boolean;
  // emits all typed characters not just valid / invalid complete id
  emitAll?: boolean;
  // it automatically add leading zeros for ins with them
  addLeadingZero: boolean;
  // If input is not empty, but value is not correct, on blur event it will fire validation
  nonEmptyError?: boolean;
}

Automatically emits invalidCzIn when length of string is valid but number is not valid identification number.

Works with formly

and use it in the template

<input ngxCzIn [formControl]="formControl" [options]="to.czInOptions>