ngx-iban
Version:
This Angular (7+) library consists of three parts:
75 lines (69 loc) • 3.09 kB
JavaScript
import { NG_VALIDATORS } from '@angular/forms';
import * as i0 from '@angular/core';
import { Input, Directive, Pipe } from '@angular/core';
import { isValidIBAN as isValidIBAN$1, electronicFormatIBAN, friendlyFormatIBAN } from 'ibantools';
const isValidIBAN = (iban, countryCode) => countryCode
? new RegExp(`^${countryCode}.*$`, 'i').test(iban) &&
isValidIBAN$1(electronicFormatIBAN(iban))
: isValidIBAN$1(electronicFormatIBAN(iban));
const ibanValidator = (countryCode) => {
return (control) => {
if (!control.value) {
return null;
}
return isValidIBAN(control.value, countryCode) ? null : { iban: true };
};
};
class IbanDirective {
validate(control) {
if (!control.value)
return null;
return isValidIBAN(control.value, this.countryCode) ? null : { iban: true };
}
/* 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: "21.1.4", ngImport: i0, type: IbanDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.4", 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: "21.1.4", 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: "21.1.4", ngImport: i0, type: IbanPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.4", ngImport: i0, type: IbanPipe, isStandalone: true, name: "iban" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.4", ngImport: i0, type: IbanPipe, decorators: [{
type: Pipe,
args: [{
name: 'iban',
standalone: true,
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { IbanDirective, IbanPipe, ibanValidator };
//# sourceMappingURL=ngx-iban.mjs.map