Files
openclaw/packages/normalization-core/src/boolean-coercion.ts
Dallin Romney febc70036f refactor: consolidate exact boolean coercion (#99750)
* refactor: consolidate exact boolean parsing

* test: fix normalization subpath resolution

* fix: resolve normalization boolean subpath
2026-07-03 19:42:06 -07:00

18 lines
438 B
TypeScript

/** Parses booleans and case-insensitive `true`/`false` string tokens. */
export function parseBoolean(value: unknown): boolean | undefined {
if (typeof value === "boolean") {
return value;
}
if (typeof value !== "string") {
return undefined;
}
const normalized = value.trim().toLowerCase();
if (normalized === "true") {
return true;
}
if (normalized === "false") {
return false;
}
return undefined;
}