Skip to content

Commit

Permalink
Improvements to structured.ts.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Feb 18, 2024
1 parent da54f5c commit 3e440d0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions client/src/components/Tool/structured.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,10 @@ function validateParameter(inputKey: string, inputValue: any, parameterModel: To
}
} else if (isGxConditional(parameterModel)) {
const testParameter = parameterModel.test_parameter;
const testParameterOptional = testParameter.optional;
let testParameterEffectivelyOptional = testParameter.optional;
if (!testParameterEffectivelyOptional && "value" in testParameter && testParameter.value !== null) {
testParameterEffectivelyOptional = true;
}
const whens = parameterModel.whens;
const testParameterName = testParameter.name;
const testParameterValue = inputValue[testParameterName];
Expand All @@ -335,8 +338,8 @@ function validateParameter(inputKey: string, inputValue: any, parameterModel: To
break;
}
}
if (!testParameterValueFoundInWhen && !testParameterOptional) {
results.push(`Non optional parameter ${testParameterName} was not found in inputs.`);
if (!testParameterValueFoundInWhen && !testParameterEffectivelyOptional) {
results.push(`Non optional conditional test parameter ${testParameterName} was not found in inputs.`);
}
}
if (checkType && !checkType(inputValue)) {
Expand Down Expand Up @@ -377,6 +380,12 @@ function validateParameters(
if (toolInput && "optional" in toolInput && toolInput.optional === true) {
continue;
}
if (toolInput && "value" in toolInput && toolInput.value !== null) {
continue;
}
if (isGxConditional(parameterModel)) {
continue;
}
results.push(`Non optional parameter ${inputKey} was not found in inputs.`);
}
return results;
Expand Down

0 comments on commit 3e440d0

Please sign in to comment.