github colinhacks/zod v1.1.2

latest releases: v3.23.8, v3.23.7, v3.23.6...
4 years ago

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

Don't miss a new zod release

NewReleases is sending notifications on new releases.