MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / getSchemaValidator

Function getSchemaValidator

packages/kernel/core/src/validation.ts:6–28  ·  view source on GitHub ↗
(
  schema: unknown,
)

Source from the content-addressed store, hash-verified

4import { KernelCoreEffectError } from "./effect-errors";
5
6const getSchemaValidator = (
7 schema: unknown,
8):
9 | ((
10 value: unknown,
11 ) => StandardSchemaV1.Result<unknown> | Promise<StandardSchemaV1.Result<unknown>>)
12 | null => {
13 if (!schema || (typeof schema !== "object" && typeof schema !== "function")) {
14 return null;
15 }
16
17 const standard = (schema as { "~standard"?: unknown })["~standard"];
18 if (!standard || typeof standard !== "object") {
19 return null;
20 }
21
22 const validate = (standard as { validate?: unknown }).validate;
23 return typeof validate === "function"
24 ? (validate as (
25 value: unknown,
26 ) => StandardSchemaV1.Result<unknown> | Promise<StandardSchemaV1.Result<unknown>>)
27 : null;
28};
29
30const formatIssuePath = (
31 path: ReadonlyArray<PropertyKey | StandardSchemaV1.PathSegment> | undefined,

Callers 1

validateInputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected