functionprocessUser(user: User, options?: ProcessOptions) { // Only assert options if they are provided assertOptional(options, isObject(options), 'Options must be an object');
// Process user... }
Example
constconfig = getConfig(); assertOptional(config.timeout, config.timeout > 0, 'Timeout must be positive');
Asserts only if value is not undefined.
Provides conditional assertion that only executes when the value is defined. Useful for validating optional parameters or properties.