recover
recover<U>(getFallback: Object): Object
Type Parameters
Parameters
getFallback: Object
Returns Object
See
fallback for usage without callback
Example
import * as x from 'unhoax'
const orString = x.recover(() => 'not a number')
const schema = orString(x.number)
// or, using pipe
import pipe from 'just-pipe'
const schema = pipe(x.number, x.recover(() => 'not a number'))
schema.parse(42) // { success: true, value: 42 }
schema.parse('toto') // { success: true, value: 'not a number' }
Allows to never fail from parsing an input by providing a fallback.