apps-script-utils 2.1.1 Help

requireGridRangeContainedIn

function requireGridRangeContainedIn( gridRange: GridRange, containerGridRange: GridRange, message?: string ): GridRange;

The assertion form of isGridRangeContainedIn. The default message names both ranges in A1 notation, which is what makes the failure readable in an execution log.

Parameters

Parameter

Type

Description

gridRange

GridRange

The grid range that must be contained.

containerGridRange

GridRange

The grid range expected to contain it.

message (optional)

string

The message of the exception. A default naming both ranges is used when omitted.

Returns

GridRange — the first range, unchanged.

Throws

Exception

Condition

InvalidGridRangeException

the first range is not contained in the second.

Examples

Guarding a write

const inner = { startRowIndex: 1, endRowIndex: 2, startColumnIndex: 1, endColumnIndex: 2 }; const outer = { startRowIndex: 0, endRowIndex: 5, startColumnIndex: 0, endColumnIndex: 5 }; requireGridRangeContainedIn(inner, outer); // => the inner range

See also

Source

src/appsscript/sheet/requireGridRangeContainedIn.ts

23 September 2026

This documentation was generated with AI (Claude) from the library's source code.