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

Function validateBatchVariables

packages/cli/src/commands/batchRender.ts:194–229  ·  view source on GitHub ↗
(
  rows: readonly Record<string, unknown>[],
  indexPath: string,
  strictVariables: boolean,
  quiet: boolean,
  json: boolean,
)

Source from the content-addressed store, hash-verified

192}
193
194function validateBatchVariables(
195 rows: readonly Record<string, unknown>[],
196 indexPath: string,
197 strictVariables: boolean,
198 quiet: boolean,
199 json: boolean,
200): number {
201 const schema = loadProjectVariableSchema(indexPath);
202 let issueCount = 0;
203 const strictRows: number[] = [];
204
205 for (let index = 0; index < rows.length; index++) {
206 const row = rows[index];
207 if (!row || Object.keys(row).length === 0) continue;
208
209 const issues = validateVariablesAgainstSchema(row, schema);
210 if (issues.length === 0) continue;
211
212 issueCount += issues.length;
213 if (!quiet && !json) {
214 console.log("");
215 console.log(c.dim(`Batch row ${index}:`));
216 }
217 reportVariableIssues(issues, { strict: false, quiet: quiet || json });
218 if (strictVariables) strictRows.push(index);
219 }
220
221 if (strictRows.length > 0) {
222 throw new BatchRenderInputError(
223 "Variable validation failed",
224 `Aborting batch due to variable issues in row ${strictRows.join(", ")} (--strict-variables mode).`,
225 );
226 }
227
228 return issueCount;
229}
230
231export function prepareBatchRender(options: PrepareBatchRenderOptions): PreparedBatchRender {
232 const batchPath = resolve(options.batchPath);

Callers 1

prepareBatchRenderFunction · 0.85

Calls 3

reportVariableIssuesFunction · 0.85

Tested by

no test coverage detected