Skip to content

Commit 83af6bc

Browse files
committed
cleanup parse boolean
1 parent acb1eba commit 83af6bc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/common/config/configUtils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,16 @@ export function commaSeparatedToArray<T extends string[]>(str: string | string[]
108108
}
109109

110110
/**
111-
* Preprocessor for boolean values that handles string "true"/"false" correctly.
111+
* Preprocessor for boolean values that handles string "false"/"0" correctly.
112112
* Zod's coerce.boolean() treats any non-empty string as true, which is not what we want.
113113
*/
114114
export function parseBoolean(val: unknown): unknown {
115115
if (typeof val === "string") {
116116
const lower = val.toLowerCase().trim();
117-
if (lower === "false" || lower === "0") return false;
118-
if (lower === "true" || lower === "1") return true;
117+
if (lower === "false" || lower === "0" || lower === "") {
118+
return false;
119+
}
120+
return true;
119121
}
120122
if (typeof val === "boolean") {
121123
return val;

0 commit comments

Comments
 (0)