MCPcopy Index your code
hub / github.com/markdoc/markdoc / validateTree

Function validateTree

src/validator.ts:335–355  ·  view source on GitHub ↗
(content: Node, config: Config)

Source from the content-addressed store, hash-verified

333}
334
335export function validateTree(content: Node, config: Config) {
336 const output = [...walkWithParents(content)].map(([node, parents]) => {
337 const updatedConfig = {
338 ...config,
339 validation: { ...config.validation, parents },
340 };
341 const errors = validator(node, updatedConfig);
342
343 if (isPromise(errors)) {
344 return errors.then((e) => e.map((error) => toValidateError(node, error)));
345 }
346
347 return errors.map((error) => toValidateError(node, error));
348 });
349
350 if (output.some(isPromise)) {
351 return Promise.all(output).then((o) => o.flat());
352 }
353
354 return output.flat();
355}

Callers 1

validateFunction · 0.90

Calls 4

isPromiseFunction · 0.90
walkWithParentsFunction · 0.85
toValidateErrorFunction · 0.85
validatorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…