Skip to content

fix(jobs): integrate zod schema middleware with validateWithFields in… - #383

Closed
Davoski1 wants to merge 1 commit into
Goldii-locks:mainfrom
Davoski1:feature/issue-115-zod-validation-partial-release
Closed

fix(jobs): integrate zod schema middleware with validateWithFields in…#383
Davoski1 wants to merge 1 commit into
Goldii-locks:mainfrom
Davoski1:feature/issue-115-zod-validation-partial-release

Conversation

@Davoski1

Copy link
Copy Markdown
Contributor

Description

Closes #115

This PR integrates Zod request shape validations as a reusable middleware handler for the POST /api/jobs/:contractId/milestones/:index/partial-release route, enabling detailed field-level validation errors.

Changes Made

  • Middleware Update: Replaced the validate middleware with validateWithFields for the partialReleaseBodySchema inside src/routes/jobs.ts. This ensures that invalid request shapes are parsed and reported back with a fields mapping (e.g., fields: { amount: "..." }) rather than just a generic array of error details.
  • Test Coverage: Updated existing validation tests in __tests__/partial-release.test.ts to assert that the new fields property is correctly returned in the JSON response payload for invalid formats (e.g. invalid amount or sourceAddress).

Verification

  • All 25 test cases for the partial-release endpoint pass successfully.
  • Invalid formats are properly caught, parsed, and reported back as specific field validation errors.
  • Code conforms to the existing repository patterns (linting, formatting, typings).

@Davoski1 Davoski1 closed this Aug 29, 2026
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.

Integrate Zod schema middleware in POST /api/jobs/:contractId/milestones/:index/partial-release

1 participant