apps-script-utils 2.1.1 Help

requireRelative

function requireRelative(path: unknown, message: string = "Expected a relative path."): string;

The exact complement of isAbsolute: anything that does not start at a root, which includes the empty string.

isX and nonX answer a question and never interrupt control flow; requireX and requireNonX hand the value back or throw. The scheme is explained in Validation conventions.

Parameters

Parameter

Type

Description

path

unknown

The value to validate as a relative path.

message (optional) = "Expected a relative path."

string

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

Returns

string — the same value, typed as a relative path.

Throws

Exception

Condition

IllegalArgumentException

the value is not a relative path.

Examples

What passes and what does not

requireRelative("docs/readme.md"); // => "docs/readme.md" requireRelative("./a"); // => "./a" requireRelative("/var/log"); // throws IllegalArgumentException requireRelative("https://example.com/a"); // throws IllegalArgumentException

See also

Source

src/net/path/requireRelative.ts

23 September 2026

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