✨ 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.
}
);