# fast-check-io-ts

> io-ts codec to fast-check arbitrary mapping

Latest version **0.5.0** (published 2021-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install fast-check-io-ts
pnpm add fast-check-io-ts
yarn add fast-check-io-ts
bun add fast-check-io-ts
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2021-01-03 |
| First published | 2019-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 32 |
| Author | Giovanni Gonzaga |
| Maintainers | giogonzo |
| Keywords | fast-check, io-ts, typescript, arbitrary, generative, testing |

## Links

- npm: https://www.npmjs.com/package/fast-check-io-ts
- Repository: https://github.com/giogonzo/fast-check-io-ts
- Issues: https://github.com/giogonzo/fast-check-io-ts/issues
- npm.io page: https://npm.io/package/fast-check-io-ts

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 0.5.0 (latest) — 2021-01-03
- 0.4.0 — 2019-10-02
- 0.3.0 — 2019-08-07
- 0.2.1 — 2019-08-07
- 0.2.0 — 2019-08-07
- 0.1.1 — 2019-08-07
- 0.1.0 — 2019-08-07

## README

# fast-check-io-ts

[io-ts](https://github.com/gcanti/io-ts) codecs mapped to [fast-check](https://github.com/dubzzz/fast-check) arbitraries.

## Usage

```ts
import * as fc from 'fast-check';
import * as t from 'io-ts';
import { getArbitrary } from 'fast-check-io-ts';

const NonEmptyString = t.brand(
  t.string,
  (s): s is t.Branded<string, { readonly NonEmptyString: symbol }> => s.length > 0,
  'NonEmptyString'
);
const User = t.type({
  name: t.string,
  status: t.union([t.literal('active'), t.literal('inactive')]),
  handle: NonEmptyString
});

const userArb = getArbitrary(User);

console.log(fc.sample(userArb, 1)[0]); // { name: '', status: 'inactive', handle: 'M.y?>A/' }
```

## Known issues

- only supports predefined `io-ts` codecs, not custom types e.g. `DateFromISOString` from `io-ts-types`
- `getArbitrary(t.keyof({ ... }))` is currently marked as error by TS, even though the codec is supported in the implementation

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