From c55e075e35a8a3a039c72e905c70ff6e7b40e4b4 Mon Sep 17 00:00:00 2001 From: mcmcphillips Date: Tue, 10 Dec 2024 10:55:54 -0800 Subject: [PATCH] MAT-7791: partial --- .../functionsSection/argumentSection/ArgumentSection.tsx | 1 + .../functionsSection/functionBuilder/FunctionBuilder.tsx | 3 +++ src/validations/FunctionArgumentSchemaValidator.ts | 7 ++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/CqlBuilderPanel/functionsSection/argumentSection/ArgumentSection.tsx b/src/CqlBuilderPanel/functionsSection/argumentSection/ArgumentSection.tsx index f084adf..7bffe06 100644 --- a/src/CqlBuilderPanel/functionsSection/argumentSection/ArgumentSection.tsx +++ b/src/CqlBuilderPanel/functionsSection/argumentSection/ArgumentSection.tsx @@ -137,6 +137,7 @@ export default function ArgumentSection(props: ArgumentsProps) { inputProps={{ "data-testid": "other-type-input", }} + // required {...formik.getFieldProps("other")} error={Boolean(formik.errors.other)} helperText={formik.errors.other} diff --git a/src/CqlBuilderPanel/functionsSection/functionBuilder/FunctionBuilder.tsx b/src/CqlBuilderPanel/functionsSection/functionBuilder/FunctionBuilder.tsx index b8c5c2e..12873a0 100644 --- a/src/CqlBuilderPanel/functionsSection/functionBuilder/FunctionBuilder.tsx +++ b/src/CqlBuilderPanel/functionsSection/functionBuilder/FunctionBuilder.tsx @@ -135,6 +135,9 @@ export default function FunctionBuilder({ if (e.target.value && !expressionEditorOpen) { setExpressionEditorOpen(true); } + if (e.target.value && !argumentsEditorOpen) { + setArgumentsEditorOpen(true); + } }} /> diff --git a/src/validations/FunctionArgumentSchemaValidator.ts b/src/validations/FunctionArgumentSchemaValidator.ts index 61c68f1..48c0373 100644 --- a/src/validations/FunctionArgumentSchemaValidator.ts +++ b/src/validations/FunctionArgumentSchemaValidator.ts @@ -6,5 +6,10 @@ export const FunctionArgumentSchemaValidator = Yup.object().shape({ "No spaces or special characters besides underscore are allowed" ), dataType: Yup.string(), - other: Yup.string(), + other: Yup.string().when("dataType", { + is: (value: any) => value === "Other", + then: (schema) => + schema.required("This field is required when dataType is 'Other'."), + otherwise: (schema) => schema, + }), });