Skip to content

Add request body schema validation with Zod and replace ad-hoc checks across routes #356

@thlpkee20-wq

Description

@thlpkee20-wq

Description

Routes use a mix of inline checks and ad-hoc validators. Centralize on Zod schemas per route, with a single validateBody(schema) middleware producing uniform error envelopes.

Requirements and context

  • Must be secure, tested, and documented
  • Should be efficient and easy to review
  • Relevant code: src/middleware/validation.ts, src/routes/
  • Migrate routes incrementally; keep one PR per route group

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b refactor/zod-body-validation
  • Implement changes
    • Add Zod dependency and shared error formatter
    • Migrate slots and booking-intent routes first
    • Document schema-per-route convention
  • Validate security and correctness assumptions

Test and commit

  • Run tests
    • npm test
  • Cover edge cases
    • Extra unknown fields are stripped, not silently accepted
  • Include test output and notes

Example commit message

refactor: Zod schemas and unified body validation

Guidelines

  • Minimum 95 percent test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend scoperefactorRefactors with no behavior changevalidation

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions