Skip to content

assertOneOf

Assert that a value is one of a set of expected values, with type-narrowing.

import { assertOneOf } from "@kensio/smartass";
const status: unknown = "active";
assertOneOf(status, ["pending", "active"] as const);
// status is now narrowed to "pending" | "active"

Source file: src/assert/one-of/one-of.assert.ts