From 06f5da154488cb3cfa95e83be8113f229d33ab88 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 21 Nov 2024 03:09:31 +0100 Subject: [PATCH] Checking for valid file types --- .../net/codinux/invoicing/service/InvoicingService.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e-invoice-api/src/main/kotlin/net/codinux/invoicing/service/InvoicingService.kt b/e-invoice-api/src/main/kotlin/net/codinux/invoicing/service/InvoicingService.kt index 2142b30..2efe69a 100644 --- a/e-invoice-api/src/main/kotlin/net/codinux/invoicing/service/InvoicingService.kt +++ b/e-invoice-api/src/main/kotlin/net/codinux/invoicing/service/InvoicingService.kt @@ -49,8 +49,10 @@ class InvoicingService { } - fun validateInvoice(invoice: Path) = - validator.validate(invoice.toFile()) + fun validateInvoice(invoiceFile: Path) =when (invoiceFile.extension.lowercase()) { + "xml", "pdf" -> validator.validate(invoiceFile.toFile()) + else -> throw IllegalArgumentException("We can only validate .xml and .pdf eInvoice files") + } private fun createTempPdfFile(): Path =