MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / buildValidationEnvelope

Function buildValidationEnvelope

packages/server/src/middleware/validate.ts:58–81  ·  view source on GitHub ↗
(
  details: ValidationDetailItem[],
  requestId: string,
)

Source from the content-addressed store, hash-verified

56}
57
58function buildValidationEnvelope(
59 details: ValidationDetailItem[],
60 requestId: string,
61): {
62 code: number;
63 msg: string;
64 data: null;
65 request_id: string;
66 details: ValidationDetailItem[];
67} {
68 const first = details[0];
69 const msg = first === undefined
70 ? 'validation failed'
71 : first.path === ''
72 ? first.message
73 : `${first.path}: ${first.message}`;
74 return {
75 code: ErrorCode.VALIDATION_FAILED,
76 msg,
77 data: null,
78 request_id: requestId,
79 details,
80 };
81}
82
83/**
84 * Build a Fastify `preHandler` that parses `req.body` against `schema`.

Callers 3

validateBodyFunction · 0.70
validateQueryFunction · 0.70
validateParamsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected