Skip to content

Add Zod schema validation for expense creation request payloads #448

Description

@Cjay-Cyber-2

Description

Implement a robust Zod validation schema for expense creation requests in the backend API to ensure all incoming payload fields (such as description, amount, currency, and participants) are correctly typed and formatted before processing.

Context & Requirements

The Mergepay backend uses Fastify and Zod for input validation. Currently, some expense endpoints lack comprehensive request body validation, risking malformed data entering the database or settlement services. We need a dedicated Zod schema for expense creation matching the client types in mergepay-web.

Acceptance Criteria

  • Create a Zod validation schema for expense creation in src/schemas/expense.schema.ts.
  • Validate description (non-empty string), amount (positive number/string representation), currency (XLM or USDC), and participant shares.
  • Integrate the schema into the expense creation route handler.
  • Add unit tests verifying successful validation and proper rejection of invalid payloads.

Implementation Guidance

  • Likely files to touch: src/schemas/expense.schema.ts, route definitions under src/routes/.
  • Follow existing Zod validation patterns found across other route handlers in the codebase.

Testing & Validation

  • Run npm test to ensure all existing and new unit tests pass successfully.

Submission Guidelines

  • Open a Pull Request referencing Closes #<issue-number>.
  • Adhere to TypeScript strict rules and existing codebase formatting standards.

Wave complexity: Trivial

Activity

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

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendcomplexity: trivialDrips Wave — small, well-bounded taskdrips-waveTracked in a Drips Wave programenhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions