Parse boolean string¶
parseBooleanString parses strict boolean string literals ("true" or "false") into actual boolean values.
It rejects all loose, coercive, or ambiguous forms. If the value is not a string, or is not exactly "true" or "false", the rule emits no parse result.
Signature¶
Through the API:
.parse('boolean');
And internally:
export const parseBooleanString: ParseRule<unknown>
(value: unknown, path: FieldPath) => ParseResult<unknown>[]
Events¶
| Event code | Description |
|---|---|
string.now.boolean |
Parsed binary string into a bigint value. |
Design rationale¶
- Accepts only exact boolean literals:
"true"or"false". - Rejects all coercive or ambiguous inputs such as
"True","FALSE","1","yes","0", or"null". - Ensures contributors can rely on strict, predictable boolean parsing.
- Produces a single parse step containing the parsed boolean and one
parseEvent. - Never guesses, normalizes, or coerces — parsing is explicit and opt‑in.
Invoke¶
parseBooleanString runs only when explicitly included in a boundary or pipeline. It is not affected by normalization mode and does not run automatically.
The rule activates when:
- The value is a string.
- The string is exactly
"true"or"false".
Examples¶
Valid boolean strings¶
parseBooleanString("true", "$");
// → [
// {
// path: "$",
// nextValue: true,
// events: [
// JaneEvent{ kind: "info", code: "string.now.boolean", ... }
// ]
// }
// ]
parseBooleanString("false", "$");
// → [
// {
// path: "$",
// nextValue: false,
// events: [
// JaneEvent{ kind: "info", code: "string.now.boolean", ... }
// ]
// }
// ]
Invalid boolean — no parse¶
parseBooleanString("True", "$"); // → []
parseBooleanString("1", "$"); // → []
parseBooleanString("yes", "$"); // → []
parseBooleanString("", "$"); // → []
Non‑string value¶
parseBooleanString(true, "$"); // → []