Skip to content

feat/Add Invoice Validation Schema#90

Open
Oluwatos94 wants to merge 1 commit intoLiquifact:mainfrom
Oluwatos94:Invoice-Validation-Schema
Open

feat/Add Invoice Validation Schema#90
Oluwatos94 wants to merge 1 commit intoLiquifact:mainfrom
Oluwatos94:Invoice-Validation-Schema

Conversation

@Oluwatos94
Copy link
Copy Markdown
Contributor

Summary

  • Added validateInvoicePayload() to src/utils/validators.js with strict validation for amount, dueDate, buyer, seller, and currency (ISO 4217)

  • Integrated payload validation into POST /api/invoices in app.js returns 400 with all errors collected in a single pass - Wired up GET /api/invoices to use invoiceService.getInvoices with validateInvoiceQueryParams (previously a
    placeholder)

  • Fixed broken src/index.js from a prior merge conflict (duplicate imports, missing AppError, broken PATCH restore handler)

    Test plan

  • Run npm test 73 tests pass across index.test.js, app.test.js, invoice.api.test.js

    • validators.js has 100% statement/line/function coverage and 100% branch coverage
    • POST /api/invoices returns 400 for: missing fields, zero/negative amount, wrong date format, empty buyer/seller, unsupported currency
    • POST /api/invoices returns 201 for a fully valid payload
    • All errors are collected and returned together (not fail-fast)

    Security notes

    • Currency validated against an explicit ISO 4217 allowlist no arbitrary string passthrough
    • Buyer/seller trimmed to prevent whitespace-only values
    • Amount checked for finiteness to reject Infinity and NaN

closes #2

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 28, 2026

@Oluwatos94 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Invoice Validation Schema

1 participant