diff --git a/app/client/src/widgets/wds/WDSRadioGroupWidget/widget/config/propertyPaneConfig/validations/defaultOptionValidation.ts b/app/client/src/widgets/wds/WDSRadioGroupWidget/widget/config/propertyPaneConfig/validations/defaultOptionValidation.ts index 542e1b4f28..e7640d8491 100644 --- a/app/client/src/widgets/wds/WDSRadioGroupWidget/widget/config/propertyPaneConfig/validations/defaultOptionValidation.ts +++ b/app/client/src/widgets/wds/WDSRadioGroupWidget/widget/config/propertyPaneConfig/validations/defaultOptionValidation.ts @@ -5,6 +5,8 @@ export function defaultOptionValidation( props: any, _: any, ): ValidationResponse { + let { options } = props; + //Checks if the value is not of object type in {{}} if (_.isObject(value)) { return { @@ -33,6 +35,36 @@ export function defaultOptionValidation( }; } + if (!Array.isArray(options) && typeof options === "string") { + try { + const parsedOptions = JSON.parse(options); + + if (Array.isArray(parsedOptions)) { + options = parsedOptions; + } else { + options = []; + } + } catch (e) { + options = []; + } + } + + // @ts-expect-error type mismatch + const valueIndex = _.findIndex(options, (option) => option.value === value); + + if (valueIndex === -1) { + return { + isValid: false, + parsed: value, + messages: [ + { + name: "ValidationError", + message: `Default value is missing in options. Please update the value.`, + }, + ], + }; + } + return { isValid: true, parsed: value,