stringOfLength
stringOfLength
Section titled “stringOfLength”Matcher for a string with exactly the expected length.
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, stringOfLength } from "@kensio/smartass";
const value: unknown = { id: "user_123",};
assertObjectMatches(value, { id: stringOfLength(8),});
// value is now narrowed to an object with an 8-character id// {// id: string & { length: 8; 0: string; ...; 7: string };// }Source
Section titled “Source”Source file: src/assert/string-length/string-length.match.ts
