Skip to content
Logo

T.tuple

A collection: a fixed number of slots, each with its own schema.

T.tuple([
  T.number.whereby({ min: 1, max: 100 }),
  T.number.whereby({ min: 1, max: 100 }),
  T.number.whereby({ min: 1, max: 100 }),
]);

Use it for "exactly these things, in this order, each possibly a different shape". A T.array repeats one shape a random number of times. A tuple has a fixed number of slots, each with its own type. Each slot also draws from its own stream, like each field of a T.object, so one slot's randomness never affects another's.

To compute a single value from several schemas without wrapping them in an object, see T.derive.