MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / validationMiddleware

Function validationMiddleware

apps/web/server/middlewares/validation.ts:3–15  ·  view source on GitHub ↗
(
  schema: any,
  value: 'body' | 'query' | 'params' = 'body' // DEPRECATE this param
)

Source from the content-addressed store, hash-verified

1import type { Response, NextFunction, Request } from '@linen/types';
2
3export default function validationMiddleware(
4 schema: any,
5 value: 'body' | 'query' | 'params' = 'body' // DEPRECATE this param
6) {
7 return (req: Request, res: Response, next: NextFunction) => {
8 try {
9 req.body = schema.parse({ ...req.params, ...req.query, ...req.body });
10 return next();
11 } catch (error: any) {
12 return res.status(400).json({ message: error.message });
13 }
14 };
15}

Callers 15

accounts.tsFile · 0.85
notifications.tsFile · 0.85
api-keys.tsFile · 0.85
profile.tsFile · 0.85
index.tsFile · 0.85
commons.tsFile · 0.85
threads.tsFile · 0.85
channels.tsFile · 0.85
index.tsFile · 0.85
index.tsFile · 0.85
index.tsFile · 0.85
index.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected