npm.io
0.5.3 • Published 3 years ago

rtio

Licence
MIT
Version
0.5.3
Deps
1
Size
287 kB
Vulns
0
Weekly
0
DeprecatedThis package is deprecated

rtio

Typescript-first schema declaration, validation library and contextual transformation. Inspired from io-ts and joi.

rtio is still in alpha. Expect bugs and api changes!

Features

  • Typescript-first library which support type inference and schema type properly.
  • Support class-based or schema-based declaration
  • Powerful schema declaration, can be used to type-guard and validation. Can also be reused for multiple use case such as json, bson, or other
  • Type coercion, allow data transformation from/to different type for input/output.
  • Fast and Extensible, build your own schema/codec/parser

Please see the documentation for more details.

inference inference

Docs

Built-in

Schema
Type Typescript Builder
string string t.string()
number number t.number()
boolean boolean t.boolean()
literal 'A' t.literal('A')
unknown unknown t.unknown()
any any t.any()
null null t.null()
nullable A | null t.nullable(t.type(A))
undefined undefined t.undefined()
optional A | undefined t.undefined(t.type(A))
array array t.array(T)
type A t.type(A)
object {a:A} t.object({a: t.type(A)})
union A | B t.union(t.type(A), t.type(B))
intersect A & B t.intersect(t.type(A), t.type(B))
Parser
Name Description
BaseParser Base parser that contain no codecs.
Parser Parser with some some built in primitive Codec. You mostly use this

Keywords