MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / validateVariables

Function validateVariables

packages/core/src/runtime/validateVariables.ts:15–33  ·  view source on GitHub ↗
(
  values: Record<string, unknown>,
  declarations: readonly CompositionVariable[],
)

Source from the content-addressed store, hash-verified

13 * failure under `--strict-variables`).
14 */
15export function validateVariables(
16 values: Record<string, unknown>,
17 declarations: readonly CompositionVariable[],
18): VariableValidationIssue[] {
19 const decls = new Map<string, CompositionVariable>();
20 for (const decl of declarations) decls.set(decl.id, decl);
21
22 const issues: VariableValidationIssue[] = [];
23 for (const [id, value] of Object.entries(values)) {
24 const decl = decls.get(id);
25 if (!decl) {
26 issues.push({ kind: "undeclared", variableId: id });
27 continue;
28 }
29 const mismatch = checkType(value, decl);
30 if (mismatch) issues.push(mismatch);
31 }
32 return issues;
33}
34
35function isPlainObject(value: unknown): value is Record<string, unknown> {
36 return typeof value === "object" && value !== null && !Array.isArray(value);

Callers 2

Calls 4

checkTypeFunction · 0.85
entriesMethod · 0.80
getMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected