Is true¶
isTrue validates that a value is the boolean literal true.
It performs a strict boolean type check and then enforces literal equality. Any non-boolean value or the literal false results in a single validation event. Otherwise, it produces no validation output.
Signature¶
Through the API:
.isTrue()
And internally:
export const isTrue: ValidationRule
(value: unknown, path: FieldPath) => Promise<ReadonlyArray<JaneEvent>>
Events¶
| Event code | Description |
|---|---|
boolean.not.boolean |
Value is not a boolean |
boolean.not.true |
Value is boolean but not true |
Design rationale¶
- Provides a strict, predictable literal
truevalidation. - First ensures the value is a boolean, then checks for exact
truevalue. - Rejects truthy values that aren't the actual boolean
true. - Useful for enforcing strict boolean requirements.
- Never coerces or normalizes — validation is explicit and opt-in.
- Emits exactly one event per failure for clarity and composability.
- Async-compatible and returns a readonly array of
JaneEventobjects.
Invoke¶
isTrue runs only when explicitly included in a boundary or pipeline. It does not run automatically.
The rule activates when:
- The value is any JavaScript value.
- If the value is not a boolean, emits
boolean.not.boolean. - If the value is a boolean but not
true, emitsboolean.not.true. - If the value is exactly
true→ returns an empty result set.
Examples¶
Valid literal true¶
await isTrue(true, "$");
// → []
Boolean false¶
await isTrue(false, "$");
// → [
// JaneEvent{
// kind: "error",
// code: "boolean.not.true",
// path: "$",
// ...
// }
// ]
Non-boolean values¶
await isTrue("true", "$");
// → [
// JaneEvent{
// kind: "error",
// code: "boolean.not.boolean",
// path: "$",
// ...
// }
// ]
await isTrue(1, "$");
// → [
// JaneEvent{
// kind: "error",
// code: "boolean.not.boolean",
// path: "$",
// ...
// }
// ]