Skip to content

feat(readValidatedBody): support readBody options#1476

Merged
pi0 merged 1 commit into
h3js:mainfrom
onmax:agent/read-validated-body-options
Jul 18, 2026
Merged

feat(readValidatedBody): support readBody options#1476
pi0 merged 1 commit into
h3js:mainfrom
onmax:agent/read-validated-body-options

Conversation

@onmax

@onmax onmax commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

readValidatedBody previously called readBody without parsing options, so multipart requests could not opt into { type: "formData" } before validation.

Its options now include the existing ReadBodyOptions and are forwarded to readBody, with a regression test covering multipart form parsing through a Zod validator.

Summary by CodeRabbit

  • New Features

    • readValidatedBody now supports body parsing options, including multipart form-data requests.
    • Validation can use parsing settings such as the request body type while preserving existing error handling.
  • Tests

    • Added coverage for validating multipart form-data and applying schema defaults.

@onmax
onmax requested a review from pi0 as a code owner July 18, 2026 03:29
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3f99572f-a9cf-4b5d-a549-ab02a5cc808d

📥 Commits

Reviewing files that changed from the base of the PR and between 75ac47d and 1ec7103.

📒 Files selected for processing (2)
  • src/utils/body.ts
  • test/validate.test.ts

📝 Walkthrough

Walkthrough

readValidatedBody now accepts ReadBodyOptions in its overloads and forwards them to readBody. A multipart form-data Zod validation test verifies parsed fields and default values.

Changes

Validated body options

Layer / File(s) Summary
Options contract and forwarding
src/utils/body.ts
readValidatedBody overloads and implementation accept ReadBodyOptions, forwarding parsing options to readBody.
Multipart validation coverage
test/validate.test.ts
Adds a multipart form-data route using { type: "formData" } and verifies the validated response includes submitted and defaulted fields.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • h3js/h3#1164: Adds the underlying ReadBodyOptions and form-data parsing support used by this change.

Suggested reviewers: pi0

Poem

I’m a bunny hopping through the form,
With fields and defaults safely warm.
Options flow, schemas agree,
Multipart magic—one, two, three!
Validated carrots for me.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: readValidatedBody now supports and forwards readBody options.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pi0
pi0 merged commit 322fa88 into h3js:main Jul 18, 2026
7 checks passed
@onmax
onmax deleted the agent/read-validated-body-options branch July 19, 2026 06:17
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.

2 participants