assertMatch

import { assertMatch } from "jsr:@ende/assert";

function

function assertMatch(actual: string, expected: RegExp, msg?: string): void

Make an assertion that actual match RegExp expected. If not then throw.

actual: string

The actual value to be matched.

expected: RegExp

The expected pattern to match.

msg?: string

The optional message to display if the assertion fails.

Example: Usage

import { assertMatch } from "@ende/assert";

assertMatch("Raptor", /Raptor/); // Doesn't throw
assertMatch("Denosaurus", /Raptor/); // Throws

Source