(content: Node, config: Config)
| 333 | } |
| 334 | |
| 335 | export 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 | } |
no test coverage detected
searching dependent graphs…