Skip to content

Releases: colinhacks/zod

v1.1.2

04 Apr 19:47
Compare
Choose a tag to compare

Implemented ZodRecord.

Usage:

const myRecord = z.record(z.object({ name: z.string() }));
type myRecord = z.TypeOf<typeof myRecord>
// => { [k: string]: { name: string } }

myRecord.parse({ 
  asdf: { name: 'Bruce' },
  1234: { name: 'Barry' },
}) // passes

myRecord.parse({ 
  id1: true
}) // TypeError

myRecord.parse({ 
  id1: true
} as any) // throws