diff options
Diffstat (limited to 'src/tools/iban-validator-and-parser/iban-validator-and-parser.service.ts')
-rw-r--r-- | src/tools/iban-validator-and-parser/iban-validator-and-parser.service.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tools/iban-validator-and-parser/iban-validator-and-parser.service.ts b/src/tools/iban-validator-and-parser/iban-validator-and-parser.service.ts new file mode 100644 index 0000000..bde71db --- /dev/null +++ b/src/tools/iban-validator-and-parser/iban-validator-and-parser.service.ts @@ -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); +} |