API reference › @evolu/common › Type › minLength
function minLength<Min>(
min: ValidateBrandFactoryNumber<Min>,
): BrandFactory<`MinLength${Min}`, ValueWithLength, MinLengthError<Min>>;
Defined in: packages/common/src/Type.ts:5426
Minimum-length Brand for values whose length is at least min.
Example
import { assertOk, String, array, minLength } from "@evolu/common";
const AtLeastThreeCharacters = minLength(3)(String);
const AtLeastTwoItems = minLength(2)(array(String));
assertOk(AtLeastThreeCharacters.fromUnknown("abc"), "abc");
assertOk(AtLeastTwoItems.fromUnknown(["a", "b"]), ["a", "b"]);