UNPKG

@prismicio/types-internal

Version:
20 lines (17 loc) 446 B
import { chain } from "fp-ts/Either" import { pipe } from "fp-ts/function" import * as t from "io-ts" export type StringFromBooleanC = t.Type<string, string, unknown> /** A codec that validates a Boolean and convert it as a string */ export default new t.Type<string, string, unknown>( "StringFromInt", t.string.is, (u, c) => pipe( t.boolean.validate(u, c), chain((i) => { return t.success(i.toString()) }), ), (i) => i, )