Search


Search something to see results

record

Type Parameters

  • Key extends PropertyKey
  • Value
  • Input = unknown

Parameters

Returns RecordSchema<Key, Value, Input>

import * as x from 'unhoax'

// Type-Driven
type MyRecord = Record<string, number>
const schema = x.record<MyRecord>(x.string, x.number)

// Infer-Driven
const schema = x.record(x.string, x.number)
type MyRecord = x.TypeOf<typeof schema>

schema.parse({ hello: 42 }) // { success: true, value: { hello: 42 } }