Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function starkIsIBAN(iban: string): boolean {
if (typeof iban === "string") {
// Since v2.0.0 of ibantools, isValidIBAN() is false if there is " " in the verified IBAN
return isValidIBAN(electronicFormatIBAN(iban));
}
return false;
}
export function starkIsBBAN(bban: string, countryCode: string = ""): boolean {
const strippedBban: string = typeof bban === "string" ? bban.replace(/\s/g, "") : bban;
if (isValidBBAN(strippedBban, countryCode.toUpperCase())) {
if (countryCode.match(/^BE/i)) {
const checkDigit: number = parseInt(strippedBban.substring(strippedBban.length - 2), 10);
const calculatedCheckDigit: number = calculateCheckDigit(strippedBban);
return checkDigit === calculatedCheckDigit;
}
return true;
}
return false;
}
validator: (v) => isValidIBAN(v),
},
rule: value => isValidIBAN(value),
hint: () =>
iban(v) {
return electronicFormatIBAN(v);
},
bic(v) {
validator: (v) => isValidBIC(v),
},