Documentation
    Preparing search index...

    Function notEquals

    • Validates deep inequality between two values using JSON comparison.

      Performs recursive comparison of objects and arrays to ensure they are NOT equal, by the same rules as equals: only the keys of the first value are compared, so a key that only the second value has does not make them different. Supports an optional exception filter to ignore specific keys during comparison. Useful for validating that data has changed, objects are different, or mutations have occurred.

      Processing cost: The shared JSON walker visits the first value and corresponding positions once; a failure additionally serializes both values for diagnostics. Space follows visited structure and reported differences.

      Type Parameters

      • X
      • Y = X

      Parameters

      • title: string

        Descriptive title used in error messages when values are equal

      • x: X

        The first value to compare

      • y: Y | null | undefined

        The second value to compare (can be null or undefined)

      • Optionalexception: (key: string) => boolean

        Optional filter function to exclude specific keys from comparison

      Returns void

      // Basic inequality
      TestValidator.notEquals(
      "user should be different after update",
      originalUser,
      updatedUser,
      );

      // Ignore timestamps in comparison
      TestValidator.notEquals(
      "user data should differ",
      originalUser,
      modifiedUser,
      (key) => key === "updatedAt",
      );

      // Validate state changes
      TestValidator.notEquals(
      "state should have changed",
      initialState,
      currentState,
      );

      // Type-safe nullable comparisons
      const mutableData: { count: number } | null = getMutableData();
      TestValidator.notEquals("should have changed", mutableData, null);

      Error when values are equal (indicating validation failure)

      contracts/common.md#principled-implementation It runs the same comparison as equals and fails when the comparison finds no difference, so two values differing only by extra keys of the second are considered equal and fail.

      contracts/common.md#clear-and-simple-design A thin wrapper over the shared comparison with the opposite outcome.

      contracts/common.md#prohibited-implementation-shortcuts The exception filter is the caller's; the function contains no key name of its own.

      contracts/common.md#meaningful-documentation The comment states that the rules are those of equals, and gives examples.