apps-script-utils 2.1.1 Help

isValidSlug

function isValidSlug(value: string): boolean;

Starts with a letter, then letters, digits, hyphens and underscores — the shape a URL segment or a key can take. Spaces, leading digits and an empty string are rejected.

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

value

string

The value to check.

Returns

boolean — true when the value is a slug; otherwise false.

Examples

What passes and what does not

isValidSlug("my-page"); // => true isValidSlug("a_1"); // => true isValidSlug("1-page"); // => false isValidSlug("my page"); // => false isValidSlug(""); // => false

See also

Source

src/lang/string/isValidSlug.ts

23 September 2026

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