From cf1b7e7a9362e8f3c5cd14265bc788a7359902b4 Mon Sep 17 00:00:00 2001 From: rkuo-danswer Date: Thu, 13 Mar 2025 20:38:25 -0700 Subject: [PATCH] add proper boolean validation to field (#4283) Co-authored-by: Richard Kuo (Onyx) --- web/src/components/credentials/lib.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web/src/components/credentials/lib.ts b/web/src/components/credentials/lib.ts index a9ab3ca19..d7ef8e1ea 100644 --- a/web/src/components/credentials/lib.ts +++ b/web/src/components/credentials/lib.ts @@ -16,7 +16,15 @@ export function createValidationSchema(json_values: Record) { const displayName = getDisplayNameForCredentialKey(key); - if (json_values[key] === null) { + if (typeof json_values[key] === "boolean") { + // Ensure false is considered valid + schemaFields[key] = Yup.boolean() + .nullable() + .default(false) + .transform((value, originalValue) => + originalValue === undefined ? false : value + ); + } else if (json_values[key] === null) { // Field is optional: schemaFields[key] = Yup.string() .trim()