Search


Search something to see results

partial

Type Parameters

  • T extends Record<string, any>

Parameters

Returns ObjectSchema<Partial<T>>

object

import * as x from 'unhoax'

const personSchema = x.object({
name: x.string,
age: x.number,
})

const fullyOptional = partial(personSchema)
const result = fullyOptional.parse({})
result // { success: true, value: {} }

const ageOptional = partial(personSchema, ['age'])
const result = ageOptional.parse({ name: 'hello' })
result // { success: true, value: { name: 'hello' } }

Type Parameters

  • T extends Record<string, any>
  • Key extends string | number | symbol

Parameters

Returns ObjectSchema<Omit<T, Key> & Partial<Pick<T, Key>>>

object

import * as x from 'unhoax'

const personSchema = x.object({
name: x.string,
age: x.number,
})

const fullyOptional = partial(personSchema)
const result = fullyOptional.parse({})
result // { success: true, value: {} }

const ageOptional = partial(personSchema, ['age'])
const result = ageOptional.parse({ name: 'hello' })
result // { success: true, value: { name: 'hello' } }