Skip to content
This repository was archived by the owner on Jun 16, 2026. It is now read-only.
This repository was archived by the owner on Jun 16, 2026. It is now read-only.

Get converted payload after validation #9

Description

@JeffreySoriano5

Hello,

I am using next-joi with next-connect and it works great.
I was wondering if there is a way for the request handler to receive the validated/converted payload.

For example:

const schema = Joi.object({
  name: Joi.string().trim(),
  number: Joi.number().integer(),
})

req.body = {
  name: "    dummy  ",
  number: "5",
}

const handler = nextConnect().post( validate({ body: schema }), async (req, res) => {
    const { name, number } = req.body

   // Here name and number are the original values
   // I would like them to be "dummy" and 5 (name trimmed and number casted to int)
  })

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    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