Descriptive title used in error messages when validation fails
The condition to validate (boolean, function, or async function)
Void or Promise
// Synchronous boolean
TestValidator.predicate("user should exist", user !== null);
// Synchronous function
TestValidator.predicate("array should be empty", () => arr.length === 0);
// Asynchronous function
await TestValidator.predicate("database should be connected",
async () => await db.ping()
);
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.