API reference › @evolu/common › Type › ValidateBrandFactoryCount

type ValidateBrandFactoryCount<Value extends number> =
  IsUnion<Value> extends false
    ? {} extends Record<`${Value}`, never>
      ? Value & Readonly<Record<BrandFactoryNumberError, never>>
      : `${Value}` extends
            `-${string}` | `${string}.${string}` | `${string}e${string}`
        ? Value & Readonly<Record<BrandFactoryCountError, never>>
        : Value
    : Value & Readonly<Record<BrandFactoryNumberError, never>>;

Defined in: packages/common/src/Type.ts:6538

Count parameter preserving literal types in a BrandFactory.

Like ValidateBrandFactoryNumber, it requires one concrete numeric literal. The literal must also be a non-negative integer, because a length, size, or entry count cannot be negative or fractional: minLength(-1) would accept every value, and maxLength(1.5) would mean maxLength(1).

Example

import { maxLength, minLength, String } from "@evolu/common";

minLength(0)(String);
// @ts-expect-error Count must be a non-negative integer.
minLength(-1)(String);
// @ts-expect-error Count must be a non-negative integer.
maxLength(1.5)(String);