Logos DX
    Preparing search index...

    Function assertOptional

    • 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.

      Type Parameters

      • T

      Parameters

      • val: T | undefined

        value to test

      • ...rest: [test: unknown, message?: string, ErrorClass?: ErrorConstructor]

      Returns void

      function processUser(user: User, options?: ProcessOptions) {
      // Only assert options if they are provided
      assertOptional(options, isObject(options), 'Options must be an object');

      // Process user...
      }
      const config = getConfig();
      assertOptional(config.timeout, config.timeout > 0, 'Timeout must be positive');