Skip to content

fix(validator): read multipart and URL-encoded bodies - #748

Merged
cpojer merged 1 commit into
voidzero-dev:mainfrom
0froq:fix/validate-form-body
Nov 8, 2026
Merged

cpojer merged 1 commit into
voidzero-dev:mainfrom
0froq:fix/validate-form-body

Conversation

@0froq

@0froq 0froq commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

Fixes #679

Description

withValidator({ body }) only called c.req.json(), so a useForm / action() upload (multipart/form-data) returned 400 before the handler. Multipart and urlencoded bodies are now parsed as form data. Bracket keys are restored to nested objects and arrays, and File values reach the schema. Booleans, numbers, dates, and null stay in the form encoding, so a multipart schema needs coercion. JSON bodies are unchanged.

Test

  • multipart file upload reaches the handler and the schema
  • a nested bracket key is restored
  • JSON body validation is unchanged
  • a bad form body is not reported as invalid JSON

withValidator parses form bodies through parseBody, restores bracketed
fields as nested objects and arrays, and leaves JSON bodies on json().

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@cpojer
cpojer merged commit 66448ab into voidzero-dev:main Nov 8, 2026
18 checks passed
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.

withValidator({ body }) rejects the multipart bodies that useForm and action() send for files

2 participants