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

v2.1.0

Choose a tag to compare

@sergioalvz sergioalvz released this 29 Jan 19:29
· 18 commits to trunk since this release

✨ New

The validation function has now support to check the headers property from the incoming request!

import Joi from "joi";
import withJoi from "next-joi";

const validate = withJoi({
  onValidationError: (_, res) => {
    return res.status(400).end();
  },
});

export default validate(
  {
    headers: Joi.object({
      "accept-language": Joi.string().valid("en"),
    }).unknown(),
  },
  (req, res) => {
    // This function will be only executed if the incoming request complies
    // with the validation schema defined above.
  }
);