feat(new tool): iban validation and parser

This commit is contained in:
Corentin Thomasset 2023-08-27 20:04:43 +02:00
parent 81bfe57cb8
commit c745f10d9f
No known key found for this signature in database
GPG key ID: DBD997E935996158
14 changed files with 278 additions and 1 deletions

View file

@ -0,0 +1,18 @@
import { ValidationErrorsIBAN } from 'ibantools';
export { getFriendlyErrors };
const ibanErrorToMessage = {
[ValidationErrorsIBAN.NoIBANProvided]: 'No IBAN provided',
[ValidationErrorsIBAN.NoIBANCountry]: 'No IBAN country',
[ValidationErrorsIBAN.WrongBBANLength]: 'Wrong BBAN length',
[ValidationErrorsIBAN.WrongBBANFormat]: 'Wrong BBAN format',
[ValidationErrorsIBAN.ChecksumNotNumber]: 'Checksum is not a number',
[ValidationErrorsIBAN.WrongIBANChecksum]: 'Wrong IBAN checksum',
[ValidationErrorsIBAN.WrongAccountBankBranchChecksum]: 'Wrong account bank branch checksum',
[ValidationErrorsIBAN.QRIBANNotAllowed]: 'QR-IBAN not allowed',
};
function getFriendlyErrors(errorCodes: ValidationErrorsIBAN[]) {
return errorCodes.map(errorCode => ibanErrorToMessage[errorCode]).filter(Boolean);
}