Skip to content

assertStringNotEmpty

Assert that a string has at least one character, with type-narrowing.

Note that this counts UTF-16 code units, not Unicode grapheme clusters.

import { assertStringNotEmpty } from "@kensio/smartass";
const value: unknown = "admin";
assertStringNotEmpty(value);
// value is now narrowed to a non-empty string

Source file: src/assert/string-not-empty/string-not-empty.assert.ts