# rtio

> Typescript-first schema declaration and validation library

Latest version **0.5.3** (published 2023-02-01) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install rtio
pnpm add rtio
yarn add rtio
bun add rtio
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.5.3 |
| Published | 2023-02-01 |
| First published | 2023-01-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 287.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Zulfikar Raditya Hernanta |
| Maintainers | hernantas |
| Keywords | typescript, runtime, schema, type, validate, validation |

## Links

- npm: https://www.npmjs.com/package/rtio
- Repository: https://github.com/hernantas/rtio
- Homepage: https://github.com/hernantas/rtio#readme
- Issues: https://github.com/hernantas/rtio/issues
- npm.io page: https://npm.io/package/rtio

## Dependencies (1)

- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 0.5.3 (latest) — 2023-02-01
- 0.5.2 — 2023-01-31
- 0.5.1 — 2023-01-31
- 0.5.0 — 2023-01-16

## README

# rtio

Typescript-first schema declaration, validation library and contextual transformation. Inspired from [io-ts](https://www.npmjs.com/package/io-ts) and [joi](https://www.npmjs.com/package/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](#docs) for more details.

![inference](../../images/ts-object.png)
![inference](../../images/ts-type-guard.png)

## Docs

- [The Idea](../../docs/pages/01-the-idea.md)
- [Getting Started](../../docs/pages/02-getting-started.md)
  - [Installation](../../docs/pages/02-getting-started.md#installation)
  - [Basic Usage](../../docs/pages/02-getting-started.md#basic-usage)
- [Schema-based declaration](../../docs/pages/03-schema.md)
- [Class-based declaration](../../docs/pages/04-class.md)
- [Parser](../../docs/pages/05-parser.md)
- [Codec](../../docs/pages/06-codec.md)

## 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 |

---
_Source: https://npm.io/package/rtio · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
