Validates that a given condition evaluates to true.
Supports synchronous boolean values, synchronous functions returning
boolean, and asynchronous functions returning Promise. The return
type is automatically inferred based on the input type.
Example
// Synchronous boolean TestValidator.predicate("user should exist")(user !== null);
// Synchronous function TestValidator.predicate("array should be empty")(() =>arr.length === 0);
// Asynchronous function awaitTestValidator.predicate("database should be connected")( async () =>awaitdb.ping() );
Throws
Error with descriptive message when condition is not satisfied
Validates that a given condition evaluates to true.
Supports synchronous boolean values, synchronous functions returning boolean, and asynchronous functions returning Promise. The return
type is automatically inferred based on the input type.
Example
Throws
Error with descriptive message when condition is not satisfied