@stndrds/schema 1.0.0-alpha.226 → 1.0.0-alpha.227

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
@@ -2736,7 +2736,7 @@ var ObjectBuilder = class {
2736
2736
  documentLayout(layout) {
2737
2737
  if (layout.presets) {
2738
2738
  for (const preset of layout.presets) {
2739
- validatePresetDepth(preset.structure, 1);
2739
+ validatePresetStructure(preset.id, preset.structure, 1);
2740
2740
  }
2741
2741
  }
2742
2742
  this.obj.documentLayout = layout;
@@ -2854,13 +2854,30 @@ var ObjectBuilder = class {
2854
2854
  function object(config) {
2855
2855
  return new ObjectBuilder(config);
2856
2856
  }
2857
- function validatePresetDepth(nodes, depth) {
2857
+ function validatePresetStructure(presetId, nodes, depth) {
2858
+ const fail = (message, detail) => {
2859
+ throw new chunkMUGKKCY3_js.ValidationError(message, [
2860
+ { path: ["documentLayout", "presets", presetId], message: detail }
2861
+ ]);
2862
+ };
2858
2863
  if (depth > MAX_PRESET_DEPTH) {
2859
- throw new Error(`Preset structure exceeds max depth of ${MAX_PRESET_DEPTH}`);
2864
+ fail(`Preset structure exceeds max depth of ${MAX_PRESET_DEPTH}`, "Preset structure too deep");
2860
2865
  }
2866
+ const seenSiblingTitles = /* @__PURE__ */ new Set();
2861
2867
  for (const node of nodes) {
2868
+ const title = node.title.trim();
2869
+ if (title.length === 0) {
2870
+ fail("Folder preset node title is required", "Empty folder title");
2871
+ }
2872
+ if (title.includes("/")) {
2873
+ fail("Folder preset node title cannot contain /", `Folder title contains /: "${title}"`);
2874
+ }
2875
+ if (seenSiblingTitles.has(title)) {
2876
+ fail("Folder preset sibling titles must be unique", `Duplicate folder title: "${title}"`);
2877
+ }
2878
+ seenSiblingTitles.add(title);
2862
2879
  if (node.children && node.children.length > 0) {
2863
- validatePresetDepth(node.children, depth + 1);
2880
+ validatePresetStructure(presetId, node.children, depth + 1);
2864
2881
  }
2865
2882
  }
2866
2883
  }
package/dist/index.mjs CHANGED
@@ -2733,7 +2733,7 @@ var ObjectBuilder = class {
2733
2733
  documentLayout(layout) {
2734
2734
  if (layout.presets) {
2735
2735
  for (const preset of layout.presets) {
2736
- validatePresetDepth(preset.structure, 1);
2736
+ validatePresetStructure(preset.id, preset.structure, 1);
2737
2737
  }
2738
2738
  }
2739
2739
  this.obj.documentLayout = layout;
@@ -2851,13 +2851,30 @@ var ObjectBuilder = class {
2851
2851
  function object(config) {
2852
2852
  return new ObjectBuilder(config);
2853
2853
  }
2854
- function validatePresetDepth(nodes, depth) {
2854
+ function validatePresetStructure(presetId, nodes, depth) {
2855
+ const fail = (message, detail) => {
2856
+ throw new ValidationError(message, [
2857
+ { path: ["documentLayout", "presets", presetId], message: detail }
2858
+ ]);
2859
+ };
2855
2860
  if (depth > MAX_PRESET_DEPTH) {
2856
- throw new Error(`Preset structure exceeds max depth of ${MAX_PRESET_DEPTH}`);
2861
+ fail(`Preset structure exceeds max depth of ${MAX_PRESET_DEPTH}`, "Preset structure too deep");
2857
2862
  }
2863
+ const seenSiblingTitles = /* @__PURE__ */ new Set();
2858
2864
  for (const node of nodes) {
2865
+ const title = node.title.trim();
2866
+ if (title.length === 0) {
2867
+ fail("Folder preset node title is required", "Empty folder title");
2868
+ }
2869
+ if (title.includes("/")) {
2870
+ fail("Folder preset node title cannot contain /", `Folder title contains /: "${title}"`);
2871
+ }
2872
+ if (seenSiblingTitles.has(title)) {
2873
+ fail("Folder preset sibling titles must be unique", `Duplicate folder title: "${title}"`);
2874
+ }
2875
+ seenSiblingTitles.add(title);
2859
2876
  if (node.children && node.children.length > 0) {
2860
- validatePresetDepth(node.children, depth + 1);
2877
+ validatePresetStructure(presetId, node.children, depth + 1);
2861
2878
  }
2862
2879
  }
2863
2880
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stndrds/schema",
3
- "version": "1.0.0-alpha.226",
3
+ "version": "1.0.0-alpha.227",
4
4
  "description": "Standard schema definitions and utilities",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -120,7 +120,7 @@
120
120
  "@standard-schema/spec": "^1.1.0",
121
121
  "libphonenumber-js": "^1.12.31",
122
122
  "zod": "^4.2.1",
123
- "@stndrds/constants": "1.0.0-alpha.226"
123
+ "@stndrds/constants": "1.0.0-alpha.227"
124
124
  },
125
125
  "devDependencies": {
126
126
  "@types/node": "^25.0.3",