Skip to content

Tuple

A tuple validates a fixed-length array where each element has its own schema. The input must have exactly as many elements as there are schemas — too few or too many elements will result in a parsing error.

import * as p from '@vbudovski/paseri';
const schema = p.tuple(p.number(), p.string());
const data = [1, 'foo'];
const result = schema.safeParse(data);
if (result.ok) {
// result.value typed as `[number, string]`.
}
Schema
p.tuple(p.number(), p.string())
Data
[1, 'foo']
Result