Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fast-check-io-ts

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-check-io-ts

io-ts codec to fast-check arbitrary mapping

  • 0.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

fast-check-io-ts

io-ts codecs mapped to fast-check arbitraries.

Usage

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

Keywords

FAQs

Package last updated on 03 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc