Checking for valid file types

This commit is contained in:
dankito 2024-11-21 03:09:31 +01:00
parent af1b49859a
commit 06f5da1544
1 changed files with 4 additions and 2 deletions

View File

@ -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 =