API reference › @evolu/common › Type › minSize
function minSize<Min extends number>(
min: ValidateBrandFactoryCount<Min>,
): BrandFactory<`MinSize${Min}`, ValueWithSize, MinSizeError<Min>>;
Defined in: packages/common/src/Type.ts:14663
Minimum-size Brand for values whose size is at least min.
Applies to set and map Outputs, whose size counts elements or
entries, and to a Blob or File from instanceOf, whose size counts
bytes. Use minLength for strings and arrays. For an exact size,
combine minSize with maxSize.
Example
import {
assertEqual,
assertErr,
assertOk,
minSize,
set,
String,
} from "@evolu/common";
const Tags = minSize(1)(set(String));
const tags = new Set(["local-first"]);
assertOk(Tags.fromUnknown(tags), tags);
const empty = new Set<string>();
const invalid = Tags.fromUnknown(empty);
assertErr(invalid, { type: "MinSize1", value: empty, min: 1 });
assertEqual(
Tags.formatError(invalid.error),
"The size 0 does not meet the minimum size of 1.",
);