fallback<T>(fallback: T): Object
Built on top of recover
fallback: T
recover
import { x } from 'unhoax'import pipe from 'just-pipe' // or from elsewhereconst schema = pipe(x.number, x.fallback('not a number'))schema.parse(42) // { success: true, value: 42 }schema.parse('toto') // { success: true, value: 'not a number' } Copy
import { x } from 'unhoax'import pipe from 'just-pipe' // or from elsewhereconst schema = pipe(x.number, x.fallback('not a number'))schema.parse(42) // { success: true, value: 42 }schema.parse('toto') // { success: true, value: 'not a number' }
import { x } from 'unhoax'const orString = x.fallback('not a number')const schema = orString(x.number) Copy
import { x } from 'unhoax'const orString = x.fallback('not a number')const schema = orString(x.number)
Built on top of recover