@json-to-office/core-docx 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4619,34 +4619,36 @@ function validateDocument(document, customComponents, options) {
4619
4619
  const errors = [...documentResult.errors || []];
4620
4620
  function validateComponents(components, pathPrefix = "children") {
4621
4621
  components.forEach((componentData, index) => {
4622
- const customComponent = customComponents.find(
4623
- (cc) => cc.name === componentData.name
4624
- );
4625
- if (!customComponent) {
4622
+ if (!componentData || typeof componentData !== "object" || Array.isArray(componentData)) {
4626
4623
  return;
4627
4624
  }
4628
- const versionEntry = resolveComponentVersion(
4629
- customComponent.name,
4630
- customComponent.versions,
4631
- componentData.version
4632
- );
4633
- const validation = validateComponentProps(
4634
- versionEntry,
4635
- componentData.props,
4636
- customComponent.name,
4637
- // Reject unknown custom props unless the caller allows them.
4638
- { clean: options?.allowUnknownFields === true }
4625
+ const customComponent = customComponents.find(
4626
+ (cc) => cc.name === componentData.name
4639
4627
  );
4640
- if (!validation.valid && validation.errors) {
4641
- const indexedErrors = validation.errors.map(
4642
- (error) => ({
4643
- ...error,
4644
- path: `${pathPrefix}[${index}].${error.path}`
4645
- })
4628
+ if (customComponent) {
4629
+ const versionEntry = resolveComponentVersion(
4630
+ customComponent.name,
4631
+ customComponent.versions,
4632
+ componentData.version
4633
+ );
4634
+ const validation = validateComponentProps(
4635
+ versionEntry,
4636
+ componentData.props,
4637
+ customComponent.name,
4638
+ // Reject unknown custom props unless the caller allows them.
4639
+ { clean: options?.allowUnknownFields === true }
4646
4640
  );
4647
- errors.push(...indexedErrors);
4641
+ if (!validation.valid && validation.errors) {
4642
+ const indexedErrors = validation.errors.map(
4643
+ (error) => ({
4644
+ ...error,
4645
+ path: `${pathPrefix}[${index}].${error.path}`
4646
+ })
4647
+ );
4648
+ errors.push(...indexedErrors);
4649
+ }
4648
4650
  }
4649
- if (componentData.children && Array.isArray(componentData.children)) {
4651
+ if (Array.isArray(componentData.children)) {
4650
4652
  validateComponents(
4651
4653
  componentData.children,
4652
4654
  `${pathPrefix}[${index}].children`