fluent-decoders is a Fluent-style API wrapper around nvie/decoders.
Note: Version is ALWAYS locked to same number as upstream decoders
library
import { array, boolean, string, tuple3 } from "@tdreyno/fluent-decoders"
interface Person {
name: string
age: string
isActive: boolean
}
const toPerson = ([name, age, isActive]): Person => ({ name, age, isActive })
const containsInt = (s: any): s is StringInt => !isNaN(parseInt(s, 10))
const personDecoder = tuple3(string, string.refine(containsInt), boolean).map(
toPerson,
)
const person = personDecoder.validate(["Name", "42", true])
// Compose
const people = array(personDecoder).validate([
["A", "4", true],
["B", "2", false],
])
yarn add @tdreyno/fluent-decoders
npm install --save @tdreyno/fluent-decoders
fluent-decoders is licensed under the Hippocratic License. It is an Ethical Source license derived from the MIT License, amended to limit the impact of the unethical use of open source software.