assertStringMatches
Assert that a string matches a regular expression, with type narrowing.
A regular expression carries no type-level shape, so this narrows an unknown value to a string and stops there.
import { assertStringMatches } from "@kensio/smartass";
const key: unknown = "2026/08/23/14/orders-1-2026-08-23-14-30-00-000";
assertStringMatches(key, /^\d{4}\/\d{2}\/\d{2}\/\d{2}\//);
// key is now narrowed to a stringSource
Section titled “Source”Source file: src/assert/string-matches/string-matches.assert.ts
