Skip to content

nonEmptyString

Matcher for a non-empty string.

Matchers are applied through assertObjectMatches, where they narrow the corresponding property type.

Type information that already exists in the calling scope is incorporated.

import { assertObjectMatches, nonEmptyString } from "@kensio/smartass";
const value: unknown = {
sequenceNumber: "49590338271490256608559692538361571095921575989136588898",
};
assertObjectMatches(value, {
sequenceNumber: nonEmptyString(),
});
// value is now narrowed to an object with a non-empty sequenceNumber
// {
// sequenceNumber: string & { 0: string };
// }

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