@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.
package/dist/index.js CHANGED
@@ -13042,34 +13042,36 @@ function validateDocument(document, customComponents, options) {
13042
13042
  const errors = [...documentResult.errors || []];
13043
13043
  function validateComponents(components, pathPrefix = "children") {
13044
13044
  components.forEach((componentData, index) => {
13045
- const customComponent = customComponents.find(
13046
- (cc) => cc.name === componentData.name
13047
- );
13048
- if (!customComponent) {
13045
+ if (!componentData || typeof componentData !== "object" || Array.isArray(componentData)) {
13049
13046
  return;
13050
13047
  }
13051
- const versionEntry = resolveComponentVersion(
13052
- customComponent.name,
13053
- customComponent.versions,
13054
- componentData.version
13055
- );
13056
- const validation = validateComponentProps(
13057
- versionEntry,
13058
- componentData.props,
13059
- customComponent.name,
13060
- // Reject unknown custom props unless the caller allows them.
13061
- { clean: options?.allowUnknownFields === true }
13048
+ const customComponent = customComponents.find(
13049
+ (cc) => cc.name === componentData.name
13062
13050
  );
13063
- if (!validation.valid && validation.errors) {
13064
- const indexedErrors = validation.errors.map(
13065
- (error) => ({
13066
- ...error,
13067
- path: `${pathPrefix}[${index}].${error.path}`
13068
- })
13051
+ if (customComponent) {
13052
+ const versionEntry = resolveComponentVersion(
13053
+ customComponent.name,
13054
+ customComponent.versions,
13055
+ componentData.version
13056
+ );
13057
+ const validation = validateComponentProps(
13058
+ versionEntry,
13059
+ componentData.props,
13060
+ customComponent.name,
13061
+ // Reject unknown custom props unless the caller allows them.
13062
+ { clean: options?.allowUnknownFields === true }
13069
13063
  );
13070
- errors.push(...indexedErrors);
13064
+ if (!validation.valid && validation.errors) {
13065
+ const indexedErrors = validation.errors.map(
13066
+ (error) => ({
13067
+ ...error,
13068
+ path: `${pathPrefix}[${index}].${error.path}`
13069
+ })
13070
+ );
13071
+ errors.push(...indexedErrors);
13072
+ }
13071
13073
  }
13072
- if (componentData.children && Array.isArray(componentData.children)) {
13074
+ if (Array.isArray(componentData.children)) {
13073
13075
  validateComponents(
13074
13076
  componentData.children,
13075
13077
  `${pathPrefix}[${index}].children`