Skip to content

Allow type checking for sub-objects of multipart/form-data objects #1155

Open
@RealmyTheMan

Description

@RealmyTheMan

What is the problem this feature would solve?

One might accept file uploads in a route like so:

({ body: t.Object({ files: t.Files() }) })

This will (naturally) only work with the "multipart/form-data" format. But this also makes it lose JSON-specific features, such as this, which might be necessary in some scenarios:

({
  body: t.Object({
    files: t.Files(),
    subObject: t.Object({ example: t.String() }) // you can never set the value of "example", i tried
  })
})

What is the feature you are proposing to solve the problem?

What if "sub-objects" (or arrays) under the body object were parsed as a JSON string (and checked against the type) when the request uses multipart/form-data?

What alternatives have you considered?

I can run JSON.parse() myself of course, but it wouldn't automatically work with the type checking system, and I'd have to do it manually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions