add proper boolean validation to field (#4283)

Co-authored-by: Richard Kuo (Onyx) <rkuo@onyx.app>
This commit is contained in:
rkuo-danswer 2025-03-13 20:38:25 -07:00 committed by GitHub
parent 63692a6bd3
commit cf1b7e7a93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,7 +16,15 @@ export function createValidationSchema(json_values: Record<string, any>) {
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()