MCPcopy Create free account
hub / github.com/FxEmbed/FxEmbed / apiOpenapiValidationHook

Function apiOpenapiValidationHook

src/realms/api/openapi-validation-hook.ts:16–28  ·  view source on GitHub ↗
(
  result,
  c
)

Source from the content-addressed store, hash-verified

14
15/** Normalizes Zod OpenAPI route validation failures to `{ code: 400, message }`. */
16export const apiOpenapiValidationHook: NonNullable<OpenAPIHonoOptions<Env>['defaultHook']> = (
17 result,
18 c
19) => {
20 if (result.success) {
21 return;
22 }
23 const message = formatZodIssues(result.error.issues);
24 for (const [header, value] of Object.entries(Constants.API_RESPONSE_HEADERS)) {
25 c.header(header, value);
26 }
27 return c.json({ code: 400 as const, message }, 400);
28};

Callers

nothing calls this directly

Calls 1

formatZodIssuesFunction · 0.85

Tested by

no test coverage detected