Skip to main content

record

Creates a schema that parses input as a Record, where the keys are strings and the values are of the given schema.

Note: Sodd's record only supports string keys, as opposed to Zod, which lets you specify the key type as well.

Example​

import { record, number } from "@sodd/core";

const ageSchema = record(number());

ageSchema.parse({ "Test McTestface": 100, "Sodd McSoddface": 43 }); // ✅
ageSchema.parse({ "Test McTestface": 100, "Sodd McSoddface": "43" }); // 🚨

Issue types​