apps-script-utils 2.1.1 Help

requireAbsolute

function requireAbsolute(path: unknown, message: string = "Expected an absolute path."): string;

A path that starts at a root: a leading /, or a scheme such as https:// or mailto:. Everything else, the empty string included, is relative.

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 an absolute path.

message (optional) = "Expected an absolute path."

string

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

Returns

string — the same value, typed as an absolute path.

Throws

Exception

Condition

IllegalArgumentException

the value is not an absolute path.

Examples

What passes and what does not

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

See also

Source

src/net/path/requireAbsolute.ts

23 September 2026

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