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, + }), });