From 66427dfbf26a04203fb81c6688345d0ea915c462 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Tue, 30 Jan 2024 19:41:05 -0500 Subject: [PATCH] Improvements to structured.ts. --- client/src/components/Tool/structured.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/client/src/components/Tool/structured.ts b/client/src/components/Tool/structured.ts index 00dab128a51c..7442963e35dd 100644 --- a/client/src/components/Tool/structured.ts +++ b/client/src/components/Tool/structured.ts @@ -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]; @@ -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)) { @@ -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;