Merge pull request #29485 from overleaf/mfb-from-joi-to-zod-clsi-cache-revert

Reapply "migrate from joi to zod CLSI-CACHE service"

GitOrigin-RevId: 638b9e21b8cf18c1733f8a01375dab4099fe5d73
This commit is contained in:
Maria Florencia Besteiro Gonzalez
2025-11-03 12:55:11 +01:00
committed by Copybot
parent c3881084be
commit 8cd2f6ac46
6 changed files with 28 additions and 24 deletions

View File

@@ -0,0 +1,17 @@
const { isZodErrorLike, fromError } = require('zod-validation-error')
/**
* @typedef {import('express').ErrorRequestHandler} ErrorRequestHandler
*/
const handleValidationError = [
/** @type {ErrorRequestHandler} */
(err, req, res, next) => {
if (!isZodErrorLike(err)) {
return next(err)
}
res.status(400).json({ ...fromError(err), statusCode: 400 })
},
]
module.exports = { handleValidationError }