value to check
function or boolean to validate the value
true if value is optional or passes the check
// With function check
function processData(data: any, timeout?: number) {
assert(isOptional(timeout, (t) => t > 0), 'Timeout must be positive');
// Process data...
}
Optional value check with custom validation.
Returns true if value is undefined/null OR if the custom check passes. Useful for validating optional parameters with specific criteria.