UNPKG

ngx-iban

Version:

This Angular (7+) library consists of three parts:

89 lines (83 loc) 4.01 kB
import { NG_VALIDATORS } from '@angular/forms'; import * as i0 from '@angular/core'; import { Input, Directive, Pipe, NgModule } from '@angular/core'; import { isValidIBAN, electronicFormatIBAN, friendlyFormatIBAN } from 'ibantools'; const ibanValidator = (countryCode) => { return (control) => { if (countryCode && control.value) { return new RegExp(`^${countryCode}.*$`, 'i').test(control.value) && isValidIBAN(electronicFormatIBAN(control.value)) ? null : { iban: { value: control.value } }; } else if (control.value) { return isValidIBAN(electronicFormatIBAN(control.value)) ? null : { iban: { value: control.value } }; } return null; }; }; class IbanDirective { validate(control) { return ibanValidator(this.countryCode)(control); } /* istanbul ignore next */ registerOnValidatorChange(fn) { this._onChange = fn; } /* istanbul ignore next */ ngOnChanges(changes) { if ('countryCode' in changes && this._onChange) { this._onChange(); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: IbanDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.3", type: IbanDirective, isStandalone: true, selector: "[ngxIban]", inputs: { countryCode: ["ngxIban", "countryCode"] }, providers: [ { provide: NG_VALIDATORS, useExisting: IbanDirective, multi: true }, ], usesOnChanges: true, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: IbanDirective, decorators: [{ type: Directive, args: [{ selector: '[ngxIban]', standalone: true, providers: [ { provide: NG_VALIDATORS, useExisting: IbanDirective, multi: true }, ], }] }], propDecorators: { countryCode: [{ type: Input, args: ['ngxIban'] }] } }); class IbanPipe { transform(value, separator) { return value ? friendlyFormatIBAN(value, separator) : null; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: IbanPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); } static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.0.3", ngImport: i0, type: IbanPipe, isStandalone: true, name: "iban" }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: IbanPipe, decorators: [{ type: Pipe, args: [{ name: 'iban', standalone: true, }] }] }); class NgxIbanModule { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgxIbanModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.3", ngImport: i0, type: NgxIbanModule, imports: [IbanDirective, IbanPipe], exports: [IbanDirective, IbanPipe] }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgxIbanModule }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgxIbanModule, decorators: [{ type: NgModule, args: [{ imports: [IbanDirective, IbanPipe], exports: [IbanDirective, IbanPipe], }] }] }); /** * Generated bundle index. Do not edit. */ export { IbanDirective, IbanPipe, NgxIbanModule, ibanValidator }; //# sourceMappingURL=ngx-iban.mjs.map