Zod #
Define a schema for any non-primitive object #
import { z } from 'zod';
const mySchema = z.record(z.unknown());
Defining required attributes while allowing additional unknown properties #
import { z } from 'zod';
const mySchema = z.object({
requiredAttribute: z.string(),
anotherRequiredAttribute: z.number()
}).passthrough();