Skip to content

Commit 9198f63

Browse files
committed
library-api: further enhance validation for local tSituation types in DMN models
now checks structure of each level of the type tree.
1 parent 89439f9 commit 9198f63

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

library-api/src/test/java/org/codeforphilly/bdt/api/SituationTypeValidationTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,27 @@ private void validateSchemaSubset(JsonNode bdtSchema, JsonNode localSchema, Stri
245245
return;
246246
}
247247

248+
// Check if local is unstructured (only x-dmn-type, no type/properties/items/$ref)
249+
boolean localHasStructure = resolvedLocal.has("type") ||
250+
resolvedLocal.has("properties") ||
251+
resolvedLocal.has("items") ||
252+
resolvedLocal.has("$ref");
253+
254+
boolean bdtHasStructure = resolvedBdt.has("type") ||
255+
resolvedBdt.has("properties") ||
256+
resolvedBdt.has("items") ||
257+
resolvedBdt.has("$ref");
258+
259+
// If BDT has structure but local doesn't, that's invalid
260+
if (bdtHasStructure && !localHasStructure) {
261+
String localType = resolvedLocal.has("x-dmn-type") ?
262+
resolvedLocal.get("x-dmn-type").asText() : "unknown";
263+
invalidPaths.add(currentPath +
264+
" [local uses unstructured type '" + localType +
265+
"' but BDT has structured type]");
266+
return;
267+
}
268+
248269
// Handle object types (have "properties")
249270
if (resolvedLocal.has("properties")) {
250271
if (!resolvedBdt.has("properties")) {

0 commit comments

Comments
 (0)