tuple
Creates a schema that validates a tuple of values. An optional rest
schema can be passed to validate the rest of the values.
Example​
import { tuple, number, object, string, boolean } from "@sodd/core";
const coordinatesSchema = tuple([number(), number()]);
coordinatesSchema.parse([1, 2]);
// ✅ => [1, 2];
// examples are hard
const weirdSchema = tuple([boolean(), object({ name: string() })], number());
weirdSchema.parse([true, { name: "Test McTestface" }, 1, 2, 3, 4]);
// ✅ => [true, { name: "Test McTestface" }, 1, 2, 3, 4];
Issue types​
InvalidTypeIssue
TooBigIssue
— Can only occur when arest
schema is not passedTooSmallIssue
- ...and any issue types from the passed schemas