8 lines
250 B
TypeScript
8 lines
250 B
TypeScript
function stringToBool(val: string | undefined, defaultValue: boolean = false): boolean {
|
|
if (!val) return defaultValue;
|
|
const normalized = val.trim().toLowerCase();
|
|
return normalized === "true" || normalized === "yes";
|
|
}
|
|
|
|
export { stringToBool };
|