Skip to content

Add Zod validation schema for expense creation and splitting payloads #456

Description

@Cjay-Cyber-2

Description — what to implement and the why/impact.

Group expense creation currently lacks robust request payload validation at the Fastify route boundary. Adding a strict Zod schema for expense creation ensures that descriptions, amounts, currency types, and participant split shares are thoroughly validated before hitting business logic or database queries.

Context & Requirements — background, constraints, design references, edge cases;

  • Grounded in src/ modules where Fastify routes are registered.
  • Must validate numeric amounts (must be positive), supported currency codes (XLM, USDC), and ensure participant split percentages or exact shares sum correctly.
  • Follow TypeScript strict rules and use Zod for validation schemas matching existing API conventions.

Acceptance Criteria — a checklist ("- [ ] ...") of specific, testable conditions that define "done".

  • Create a Zod schema file or export for expense creation payloads.
  • Validate title (non-empty string), amount (positive number), currency ('XLM' | 'USDC'), and split array.
  • Add unit tests verifying invalid payloads are rejected with descriptive error messages and valid payloads pass successfully.

Implementation Guidance — likely files/modules to touch

  • Likely files: src/schemas/expense.ts (or equivalent schema directory) and associated route files under src/routes/.
  • Suggested approach: Define the schema using z.object(), attach it to Fastify route options, and write unit tests using Vitest.

Testing & Validation — how the contributor should prove it works

  • Run npm test to verify all tests pass, including new validation unit tests.

Submission Guidelines — must open a PR that includes "Closes #"; assignment is required before starting.


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