Skip to content

A sellection of essential io-ts types for decoding io like url queries and such.

Notifications You must be signed in to change notification settings

piing-as/io-types

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@piing/io-types

A sellection of essential io-ts types for decoding io like url queries and such.

Install

npm i @piing/io-types

Examples

import * as io from "io-ts"

import { ArrayFromJSONString } from "@piing/io-types/lib/ArrayFromJSONString"
import { Nullable } from "@piing/io-types/lib/Nullable"
import { YesNoBool } from "@piing/io-types/lib/YesNoBool"


const JSONNumberArray = ArrayFromJSONString(io.number);
const JSONStringArray = ArrayFromJSONString(io.string);

JSONNumberArray.decode("[1,2,3]") // right [1,2,3]
JSONStringArray.decode(`["foo", "bar"]`) // right ["foo", "bar"]


const NullableNumber = Nullable(io.number)

NullableNumber.decode(null) // right null
NullableNumber.decode(1) // right 1


YesNoBool.decode("yes") // right true
YesNoBool.decode("no") // right false

About

A sellection of essential io-ts types for decoding io like url queries and such.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published