MCPcopy Create free account
hub / github.com/ForestHubAI/edge-agents / validateComponent

Function validateComponent

ts/workflow-cli/cli/deploy/components.ts:83–94  ·  view source on GitHub ↗
(data: unknown)

Source from the content-addressed store, hash-verified

81// per failure (empty array = valid). The shared single-item check behind both the
82// batch parse and the interactive folder prompt, so both reject the same shapes.
83export function validateComponent(data: unknown): string[] {
84 const validate = compileDeployComponentValidator();
85 if (validate(data)) return [];
86 return (validate.errors ?? []).map((e) => {
87 const p = e.params as Record<string, unknown>;
88 // Name the offending key for the two errors where it's the whole point:
89 // an unknown/typo'd property and a missing required one.
90 const which = p.additionalProperty ?? p.missingProperty;
91 const detail = typeof which === "string" ? ` "${which}"` : "";
92 return `${e.instancePath || "/"} ${e.message ?? "invalid"}${detail}`;
93 });
94}
95
96// Validates each parsed component.json against the contract, collecting every
97// failure as "<source>: <message>" before throwing — the same all-at-once style as

Callers 3

components.test.tsFile · 0.90
parseDeployComponentsFunction · 0.85
promptCustomComponentsFunction · 0.85

Calls 1

Tested by

no test coverage detected