BooleanFromNumber overview
Added in v0.5.13
Table of contents
BooleanFromNumberC (interface)
Signature
export interface BooleanFromNumberC extends t.Type<boolean, number, unknown> {}
Added in v0.5.13
BooleanFromNumber
Signature
export const BooleanFromNumber: BooleanFromNumberC = ...
Example
import { BooleanFromNumber } from 'io-ts-types/lib/BooleanFromNumber'
import { right } from 'fp-ts/lib/Either'
import { PathReporter } from 'io-ts/lib/PathReporter'
assert.deepStrictEqual(BooleanFromNumber.decode(1), right(true))
assert.deepStrictEqual(BooleanFromNumber.decode(0), right(false))
assert.deepStrictEqual(BooleanFromNumber.decode(123), right(true))
assert.deepStrictEqual(PathReporter.report(BooleanFromNumber.decode('a')), [
'Invalid value "a" supplied to : BooleanFromNumber'
])
Added in v0.5.13