diff --git a/src/tools/iban-validator-and-parser/iban-validator-and-parser.vue b/src/tools/iban-validator-and-parser/iban-validator-and-parser.vue index 641628d7..f143ae80 100644 --- a/src/tools/iban-validator-and-parser/iban-validator-and-parser.vue +++ b/src/tools/iban-validator-and-parser/iban-validator-and-parser.vue @@ -7,50 +7,67 @@ import { useQueryParam } from '@/composable/queryParams'; const { t } = useI18n(); -const rawIban = useQueryParam({ tool: 'iban-validator', name: 'iban', defaultValue: '' }); +const rawIbans = useQueryParam({ tool: 'iban-validator', name: 'iban', defaultValue: '' }); -const ibanInfo = computed(() => { - const iban = rawIban.value.toUpperCase().replace(/\s/g, '').replace(/-/g, ''); +interface IbanInfo { + iban: string + infos: CKeyValueListItems +} - if (iban === '') { +const ibansInfo = computed(() => { + if (!rawIbans.value?.trim()) { + return []; + } + const ibans = rawIbans.value.toUpperCase() + .split(/\n/).map(iban => iban.replace(/\s/g, '').replace(/-/g, '')) + .filter(Boolean); + + if (!ibans.length) { return []; } - const { valid: isIbanValid, errorCodes } = validateIBAN(iban); - const { countryCode, bban } = extractIBAN(iban); - const errors = getFriendlyErrors(errorCodes); + const results: IbanInfo[] = []; - return [ + for (const iban of ibans) { + const { valid: isIbanValid, errorCodes } = validateIBAN(iban); + const { countryCode, bban } = extractIBAN(iban); + const errors = getFriendlyErrors(errorCodes); - { - label: t('tools.iban-validator-and-parser.texts.label-is-iban-valid'), - value: isIbanValid, - showCopyButton: false, - }, - { - label: t('tools.iban-validator-and-parser.texts.label-iban-errors'), - value: errors.length === 0 ? undefined : errors, - hideOnNil: true, - showCopyButton: false, - }, - { - label: t('tools.iban-validator-and-parser.texts.label-is-iban-a-qr-iban'), - value: isQRIBAN(iban), - showCopyButton: false, - }, - { - label: t('tools.iban-validator-and-parser.texts.label-country-code'), - value: countryCode, - }, - { - label: t('tools.iban-validator-and-parser.texts.label-bban'), - value: bban, - }, - { - label: t('tools.iban-validator-and-parser.texts.label-iban-friendly-format'), - value: friendlyFormatIBAN(iban), - }, - ]; + results.push({ + iban, + infos: [ + { + label: t('tools.iban-validator-and-parser.texts.label-is-iban-valid'), + value: isIbanValid, + showCopyButton: false, + }, + { + label: t('tools.iban-validator-and-parser.texts.label-iban-errors'), + value: errors.length === 0 ? undefined : errors, + hideOnNil: true, + showCopyButton: false, + }, + { + label: t('tools.iban-validator-and-parser.texts.label-is-iban-a-qr-iban'), + value: isQRIBAN(iban), + showCopyButton: false, + }, + { + label: t('tools.iban-validator-and-parser.texts.label-country-code'), + value: countryCode, + }, + { + label: t('tools.iban-validator-and-parser.texts.label-bban'), + value: bban, + }, + { + label: t('tools.iban-validator-and-parser.texts.label-iban-friendly-format'), + value: friendlyFormatIBAN(iban), + }, + ], + }); + } + return results; }); const ibanExamples = [ @@ -62,10 +79,18 @@ const ibanExamples = [