mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
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:
committed by
Copybot
parent
c3881084be
commit
8cd2f6ac46
17
libraries/validation-tools/handleValidationError.js
Normal file
17
libraries/validation-tools/handleValidationError.js
Normal 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 }
|
||||
Reference in New Issue
Block a user