Skip to content

v1.1.2

Compare
Choose a tag to compare
@colinhacks colinhacks released this 04 Apr 19:47

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