Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

io-ts-excess

goooseman31.2kMIT1.0.1TypeScript support: included

Decoder for io-ts to check, that object is exactly the same

io-ts, exact, excess

readme

io-ts-excess

A type for io-ts library, which will fail on any additional properties.

Thanks to @gcanti for the original code.

Warning! Does not work from inside intersection!

Usage

import * as t from "io-ts";
import excess from "io-ts-excess";

const C = excess(
  t.type({
    a: t.string,
  }),
);

import { PathReporter } from "io-ts/lib/PathReporter";

console.log(PathReporter.report(C.decode({ a: "a", b: 1 })));
// [ 'Invalid value {"a":"a","b":1} supplied to : { a: string }, excess properties: ["b"]' ]

TODO

  • <input disabled="" type="checkbox"> Make it to work inside intersection. The following code does not work for now: `typescript const I = t.intersection([C, t.type({ b: t.number })])

console.log(PathReporter.report(I.decode({ a: 'a', b: 1 }))) // [ 'Invalid value {"a":"a","b":1} supplied to : { a: string }, excess properties: ["b"]' ] `