Skip to content

Commit 97bcf88

Browse files
committed
Improvements to structured.ts.
1 parent 33c0b67 commit 97bcf88

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

client/src/components/Tool/structured.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,10 @@ function validateParameter(inputKey: string, inputValue: any, parameterModel: To
319319
}
320320
} else if (isGxConditional(parameterModel)) {
321321
const testParameter = parameterModel.test_parameter;
322-
const testParameterOptional = testParameter.optional;
322+
let testParameterEffectivelyOptional = testParameter.optional;
323+
if (!testParameterEffectivelyOptional && "value" in testParameter && testParameter.value !== null) {
324+
testParameterEffectivelyOptional = true;
325+
}
323326
const whens = parameterModel.whens;
324327
const testParameterName = testParameter.name;
325328
const testParameterValue = inputValue[testParameterName];
@@ -335,8 +338,8 @@ function validateParameter(inputKey: string, inputValue: any, parameterModel: To
335338
break;
336339
}
337340
}
338-
if (!testParameterValueFoundInWhen && !testParameterOptional) {
339-
results.push(`Non optional parameter ${testParameterName} was not found in inputs.`);
341+
if (!testParameterValueFoundInWhen && !testParameterEffectivelyOptional) {
342+
results.push(`Non optional conditional test parameter ${testParameterName} was not found in inputs.`);
340343
}
341344
}
342345
if (checkType && !checkType(inputValue)) {
@@ -377,6 +380,12 @@ function validateParameters(
377380
if (toolInput && "optional" in toolInput && toolInput.optional === true) {
378381
continue;
379382
}
383+
if (toolInput && "value" in toolInput && toolInput.value !== null) {
384+
continue;
385+
}
386+
if (isGxConditional(parameterModel)) {
387+
continue;
388+
}
380389
results.push(`Non optional parameter ${inputKey} was not found in inputs.`);
381390
}
382391
return results;

0 commit comments

Comments
 (0)