Socket
Socket
Sign inDemoInstall

io-ts

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io-ts - npm Package Compare versions

Comparing version 1.5.3 to 1.6.0

14

CHANGELOG.md

@@ -17,2 +17,16 @@ # Changelog

# 1.6.0
**Important**. This version requires `typescript@3.2.2+`
- **New Feature**
- leverage `typescript@3.2.2` (@gcanti)
- `TypeC`
- `PartialC`
- `RecordC`
- `UnionC`
- `ReadonlyC`
- `StrictC`
- `TaggedUnionC`
# 1.5.3

@@ -19,0 +33,0 @@

136

lib/index.d.ts

@@ -23,3 +23,3 @@ import { Either } from 'fp-ts/lib/Either';

export interface ValidationError {
readonly value: mixed;
readonly value: unknown;
readonly context: Context;

@@ -39,3 +39,3 @@ }

*/
export declare type Is<A> = (m: mixed) => m is A;
export declare type Is<A> = (u: unknown) => u is A;
/**

@@ -61,3 +61,3 @@ * @since 1.0.0

*/
export interface Mixed extends Type<any, any, mixed> {
export interface Mixed extends Type<any, any, unknown> {
}

@@ -67,11 +67,11 @@ /**

*/
export declare type TypeOf<RT extends Any> = RT['_A'];
export declare type TypeOf<C extends Any> = C['_A'];
/**
* @since 1.0.0
*/
export declare type InputOf<RT extends Any> = RT['_I'];
export declare type InputOf<C extends Any> = C['_I'];
/**
* @since 1.0.0
*/
export declare type OutputOf<RT extends Any> = RT['_O'];
export declare type OutputOf<C extends Any> = C['_O'];
/**

@@ -94,3 +94,3 @@ * @since 1.0.0

*/
export declare class Type<A, O = A, I = mixed> implements Decoder<I, A>, Encoder<A, O> {
export declare class Type<A, O = A, I = unknown> implements Decoder<I, A>, Encoder<A, O> {
/** a unique name for this runtime type */

@@ -304,3 +304,3 @@ readonly name: string;

*/
export declare class AnyArrayType extends Type<Array<mixed>> {
export declare class AnyArrayType extends Type<Array<unknown>> {
readonly _tag: 'AnyArrayType';

@@ -319,3 +319,3 @@ constructor();

export declare class AnyDictionaryType extends Type<{
[key: string]: mixed;
[key: string]: unknown;
}> {

@@ -369,7 +369,7 @@ readonly _tag: 'AnyDictionaryType';

*/
export declare class RefinementType<RT extends Any, A = any, O = A, I = mixed> extends Type<A, O, I> {
readonly type: RT;
export declare class RefinementType<C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {
readonly type: C;
readonly predicate: Predicate<A>;
readonly _tag: 'RefinementType';
constructor(name: string, is: RefinementType<RT, A, O, I>['is'], validate: RefinementType<RT, A, O, I>['validate'], encode: RefinementType<RT, A, O, I>['encode'], type: RT, predicate: Predicate<A>);
constructor(name: string, is: RefinementType<C, A, O, I>['is'], validate: RefinementType<C, A, O, I>['validate'], encode: RefinementType<C, A, O, I>['encode'], type: C, predicate: Predicate<A>);
}

@@ -384,3 +384,3 @@ /**

*/
export declare const refinement: <RT extends Any>(type: RT, predicate: Predicate<RT["_A"]>, name?: string) => RefinementC<RT>;
export declare const refinement: <C extends Any>(type: C, predicate: Predicate<C["_A"]>, name?: string) => RefinementC<C>;
/**

@@ -412,3 +412,3 @@ * @since 1.0.0

export declare class KeyofType<D extends {
[key: string]: mixed;
[key: string]: unknown;
}> extends Type<keyof D> {

@@ -423,3 +423,3 @@ readonly keys: D;

export interface KeyofC<D extends {
[key: string]: mixed;
[key: string]: unknown;
}> extends KeyofType<D> {

@@ -436,7 +436,7 @@ }

*/
export declare class RecursiveType<RT extends Any, A = any, O = A, I = mixed> extends Type<A, O, I> {
export declare class RecursiveType<C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {
private runDefinition;
readonly _tag: 'RecursiveType';
constructor(name: string, is: RecursiveType<RT, A, O, I>['is'], validate: RecursiveType<RT, A, O, I>['validate'], encode: RecursiveType<RT, A, O, I>['encode'], runDefinition: () => RT);
readonly type: RT;
constructor(name: string, is: RecursiveType<C, A, O, I>['is'], validate: RecursiveType<C, A, O, I>['validate'], encode: RecursiveType<C, A, O, I>['encode'], runDefinition: () => C);
readonly type: C;
}

@@ -446,10 +446,10 @@ /**

*/
export declare const recursion: <A, O = A, I = unknown, RT extends Type<A, O, I> = Type<A, O, I>>(name: string, definition: (self: RT) => RT) => RecursiveType<RT, A, O, I>;
export declare const recursion: <A, O = A, I = unknown, C extends Type<A, O, I> = Type<A, O, I>>(name: string, definition: (self: C) => C) => RecursiveType<C, A, O, I>;
/**
* @since 1.0.0
*/
export declare class ArrayType<RT extends Any, A = any, O = A, I = mixed> extends Type<A, O, I> {
readonly type: RT;
export declare class ArrayType<C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {
readonly type: C;
readonly _tag: 'ArrayType';
constructor(name: string, is: ArrayType<RT, A, O, I>['is'], validate: ArrayType<RT, A, O, I>['validate'], encode: ArrayType<RT, A, O, I>['encode'], type: RT);
constructor(name: string, is: ArrayType<C, A, O, I>['is'], validate: ArrayType<C, A, O, I>['validate'], encode: ArrayType<C, A, O, I>['encode'], type: C);
}

@@ -464,7 +464,7 @@ /**

*/
export declare const array: <RT extends Mixed>(type: RT, name?: string) => ArrayC<RT>;
export declare const array: <C extends Mixed>(type: C, name?: string) => ArrayC<C>;
/**
* @since 1.0.0
*/
export declare class InterfaceType<P, A = any, O = A, I = mixed> extends Type<A, O, I> {
export declare class InterfaceType<P, A = any, O = A, I = unknown> extends Type<A, O, I> {
readonly props: P;

@@ -501,3 +501,7 @@ readonly _tag: 'InterfaceType';

*/
export interface TypeC<P extends Props> extends InterfaceType<P, TypeOfProps<P>, OutputOfProps<P>, unknown> {
export interface TypeC<P extends Props> extends InterfaceType<P, {
[K in keyof P]: TypeOf<P[K]>;
}, {
[K in keyof P]: OutputOf<P[K]>;
}, unknown> {
}

@@ -512,3 +516,3 @@ /**

*/
export declare class PartialType<P, A = any, O = A, I = mixed> extends Type<A, O, I> {
export declare class PartialType<P, A = any, O = A, I = unknown> extends Type<A, O, I> {
readonly props: P;

@@ -533,3 +537,7 @@ readonly _tag: 'PartialType';

*/
export interface PartialC<P extends Props> extends PartialType<P, TypeOfPartialProps<P>, OutputOfPartialProps<P>, unknown> {
export interface PartialC<P extends Props> extends PartialType<P, {
[K in keyof P]?: TypeOf<P[K]>;
}, {
[K in keyof P]?: OutputOf<P[K]>;
}, unknown> {
}

@@ -543,3 +551,3 @@ /**

*/
export declare class DictionaryType<D extends Any, C extends Any, A = any, O = A, I = mixed> extends Type<A, O, I> {
export declare class DictionaryType<D extends Any, C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {
readonly domain: D;

@@ -565,3 +573,7 @@ readonly codomain: C;

*/
export interface RecordC<D extends Mixed, C extends Mixed> extends DictionaryType<D, C, TypeOfDictionary<D, C>, OutputOfDictionary<D, C>, unknown> {
export interface RecordC<D extends Mixed, C extends Mixed> extends DictionaryType<D, C, {
[K in TypeOf<D>]: TypeOf<C>;
}, {
[K in OutputOf<D>]: OutputOf<C>;
}, unknown> {
}

@@ -575,6 +587,6 @@ /**

*/
export declare class UnionType<RTS extends Array<Any>, A = any, O = A, I = mixed> extends Type<A, O, I> {
readonly types: RTS;
export declare class UnionType<CS extends Array<Any>, A = any, O = A, I = unknown> extends Type<A, O, I> {
readonly types: CS;
readonly _tag: 'UnionType';
constructor(name: string, is: UnionType<RTS, A, O, I>['is'], validate: UnionType<RTS, A, O, I>['validate'], encode: UnionType<RTS, A, O, I>['encode'], types: RTS);
constructor(name: string, is: UnionType<CS, A, O, I>['is'], validate: UnionType<CS, A, O, I>['validate'], encode: UnionType<CS, A, O, I>['encode'], types: CS);
}

@@ -589,10 +601,10 @@ /**

*/
export declare const union: <RTS extends [Mixed, Mixed, ...Mixed[]]>(types: RTS, name?: string) => UnionC<RTS>;
export declare const union: <CS extends [Mixed, Mixed, ...Mixed[]]>(types: CS, name?: string) => UnionC<CS>;
/**
* @since 1.0.0
*/
export declare class IntersectionType<RTS extends Array<Any>, A = any, O = A, I = mixed> extends Type<A, O, I> {
readonly types: RTS;
export declare class IntersectionType<CS extends Array<Any>, A = any, O = A, I = unknown> extends Type<A, O, I> {
readonly types: CS;
readonly _tag: 'IntersectionType';
constructor(name: string, is: IntersectionType<RTS, A, O, I>['is'], validate: IntersectionType<RTS, A, O, I>['validate'], encode: IntersectionType<RTS, A, O, I>['encode'], types: RTS);
constructor(name: string, is: IntersectionType<CS, A, O, I>['is'], validate: IntersectionType<CS, A, O, I>['validate'], encode: IntersectionType<CS, A, O, I>['encode'], types: CS);
}

@@ -622,6 +634,6 @@ /**

*/
export declare class TupleType<RTS extends Array<Any>, A = any, O = A, I = mixed> extends Type<A, O, I> {
readonly types: RTS;
export declare class TupleType<CS extends Array<Any>, A = any, O = A, I = unknown> extends Type<A, O, I> {
readonly types: CS;
readonly _tag: 'TupleType';
constructor(name: string, is: TupleType<RTS, A, O, I>['is'], validate: TupleType<RTS, A, O, I>['validate'], encode: TupleType<RTS, A, O, I>['encode'], types: RTS);
constructor(name: string, is: TupleType<CS, A, O, I>['is'], validate: TupleType<CS, A, O, I>['validate'], encode: TupleType<CS, A, O, I>['encode'], types: CS);
}

@@ -644,6 +656,6 @@ /**

*/
export declare class ReadonlyType<RT extends Any, A = any, O = A, I = mixed> extends Type<A, O, I> {
readonly type: RT;
export declare class ReadonlyType<C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {
readonly type: C;
readonly _tag: 'ReadonlyType';
constructor(name: string, is: ReadonlyType<RT, A, O, I>['is'], validate: ReadonlyType<RT, A, O, I>['validate'], encode: ReadonlyType<RT, A, O, I>['encode'], type: RT);
constructor(name: string, is: ReadonlyType<C, A, O, I>['is'], validate: ReadonlyType<C, A, O, I>['validate'], encode: ReadonlyType<C, A, O, I>['encode'], type: C);
}

@@ -653,3 +665,7 @@ /**

*/
export interface ReadonlyC<C extends Mixed> extends ReadonlyType<C, Readonly<TypeOf<C>>, Readonly<OutputOf<C>>, unknown> {
export interface ReadonlyC<C extends Mixed> extends ReadonlyType<C, {
readonly [K in keyof TypeOf<C>]: TypeOf<C>[K];
}, {
readonly [K in keyof OutputOf<C>]: OutputOf<C>[K];
}, unknown> {
}

@@ -659,10 +675,10 @@ /**

*/
export declare const readonly: <RT extends Mixed>(type: RT, name?: string) => ReadonlyC<RT>;
export declare const readonly: <C extends Mixed>(type: C, name?: string) => ReadonlyC<C>;
/**
* @since 1.0.0
*/
export declare class ReadonlyArrayType<RT extends Any, A = any, O = A, I = mixed> extends Type<A, O, I> {
readonly type: RT;
export declare class ReadonlyArrayType<C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {
readonly type: C;
readonly _tag: 'ReadonlyArrayType';
constructor(name: string, is: ReadonlyArrayType<RT, A, O, I>['is'], validate: ReadonlyArrayType<RT, A, O, I>['validate'], encode: ReadonlyArrayType<RT, A, O, I>['encode'], type: RT);
constructor(name: string, is: ReadonlyArrayType<C, A, O, I>['is'], validate: ReadonlyArrayType<C, A, O, I>['validate'], encode: ReadonlyArrayType<C, A, O, I>['encode'], type: C);
}

@@ -677,7 +693,7 @@ /**

*/
export declare const readonlyArray: <RT extends Mixed>(type: RT, name?: string) => ReadonlyArrayC<RT>;
export declare const readonlyArray: <C extends Mixed>(type: C, name?: string) => ReadonlyArrayC<C>;
/**
* @since 1.0.0
*/
export declare class StrictType<P, A = any, O = A, I = mixed> extends Type<A, O, I> {
export declare class StrictType<P, A = any, O = A, I = unknown> extends Type<A, O, I> {
readonly props: P;

@@ -690,3 +706,7 @@ readonly _tag: 'StrictType';

*/
export interface StrictC<P extends Props> extends StrictType<P, TypeOfProps<P>, OutputOfProps<P>, unknown> {
export interface StrictC<P extends Props> extends StrictType<P, {
[K in keyof P]: TypeOf<P[K]>;
}, {
[K in keyof P]: OutputOf<P[K]>;
}, unknown> {
}

@@ -744,5 +764,5 @@ /**

*/
export declare class TaggedUnionType<Tag extends string, RTS extends Array<Tagged<Tag>>, A = any, O = A, I = mixed> extends UnionType<RTS, A, O, I> {
export declare class TaggedUnionType<Tag extends string, CS extends Array<Tagged<Tag>>, A = any, O = A, I = unknown> extends UnionType<CS, A, O, I> {
readonly tag: Tag;
constructor(name: string, is: TaggedUnionType<Tag, RTS, A, O, I>['is'], validate: TaggedUnionType<Tag, RTS, A, O, I>['validate'], encode: TaggedUnionType<Tag, RTS, A, O, I>['encode'], types: RTS, tag: Tag);
constructor(name: string, is: TaggedUnionType<Tag, CS, A, O, I>['is'], validate: TaggedUnionType<Tag, CS, A, O, I>['validate'], encode: TaggedUnionType<Tag, CS, A, O, I>['encode'], types: CS, tag: Tag);
}

@@ -757,10 +777,10 @@ /**

*/
export declare const taggedUnion: <Tag extends string, RTS extends [Tagged<Tag, any, any>, Tagged<Tag, any, any>, ...Tagged<Tag, any, any>[]]>(tag: Tag, types: RTS, name?: string) => TaggedUnionC<Tag, RTS>;
export declare const taggedUnion: <Tag extends string, CS extends [Tagged<Tag, any, any>, Tagged<Tag, any, any>, ...Tagged<Tag, any, any>[]]>(tag: Tag, types: CS, name?: string) => TaggedUnionC<Tag, CS>;
/**
* @since 1.1.0
*/
export declare class ExactType<RT extends Any, A = any, O = A, I = mixed> extends Type<A, O, I> {
readonly type: RT;
export declare class ExactType<C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {
readonly type: C;
readonly _tag: 'ExactType';
constructor(name: string, is: ExactType<RT, A, O, I>['is'], validate: ExactType<RT, A, O, I>['validate'], encode: ExactType<RT, A, O, I>['encode'], type: RT);
constructor(name: string, is: ExactType<C, A, O, I>['is'], validate: ExactType<C, A, O, I>['validate'], encode: ExactType<C, A, O, I>['encode'], type: C);
}

@@ -794,3 +814,3 @@ /**

*/
export declare function exact<RT extends HasProps>(type: RT, name?: string): ExactC<RT>;
export declare function exact<C extends HasProps>(type: C, name?: string): ExactC<C>;
/**

@@ -801,3 +821,3 @@ * Drops the runtime type "kind"

*/
export declare function clean<A, O = A, I = mixed>(type: Type<A, O, I>): Type<A, O, I>;
export declare function clean<A, O = A, I = unknown>(type: Type<A, O, I>): Type<A, O, I>;
/**

@@ -804,0 +824,0 @@ * @since 1.0.0

@@ -135,3 +135,3 @@ "use strict";

function NullType() {
var _this = _super.call(this, 'null', function (m) { return m === null; }, function (m, c) { return (_this.is(m) ? exports.success(m) : exports.failure(m, c)); }, exports.identity) || this;
var _this = _super.call(this, 'null', function (u) { return u === null; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this;
_this._tag = 'NullType';

@@ -155,3 +155,3 @@ return _this;

function UndefinedType() {
var _this = _super.call(this, 'undefined', function (m) { return m === void 0; }, function (m, c) { return (_this.is(m) ? exports.success(m) : exports.failure(m, c)); }, exports.identity) || this;
var _this = _super.call(this, 'undefined', function (u) { return u === void 0; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this;
_this._tag = 'UndefinedType';

@@ -224,3 +224,3 @@ return _this;

function NeverType() {
var _this = _super.call(this, 'never', function (_) { return false; }, function (m, c) { return exports.failure(m, c); },
var _this = _super.call(this, 'never', function (_) { return false; }, function (u, c) { return exports.failure(u, c); },
/* istanbul ignore next */

@@ -246,3 +246,3 @@ function () {

function StringType() {
var _this = _super.call(this, 'string', function (m) { return typeof m === 'string'; }, function (m, c) { return (_this.is(m) ? exports.success(m) : exports.failure(m, c)); }, exports.identity) || this;
var _this = _super.call(this, 'string', function (u) { return typeof u === 'string'; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this;
_this._tag = 'StringType';

@@ -264,3 +264,3 @@ return _this;

function NumberType() {
var _this = _super.call(this, 'number', function (m) { return typeof m === 'number'; }, function (m, c) { return (_this.is(m) ? exports.success(m) : exports.failure(m, c)); }, exports.identity) || this;
var _this = _super.call(this, 'number', function (u) { return typeof u === 'number'; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this;
_this._tag = 'NumberType';

@@ -282,3 +282,3 @@ return _this;

function BooleanType() {
var _this = _super.call(this, 'boolean', function (m) { return typeof m === 'boolean'; }, function (m, c) { return (_this.is(m) ? exports.success(m) : exports.failure(m, c)); }, exports.identity) || this;
var _this = _super.call(this, 'boolean', function (u) { return typeof u === 'boolean'; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this;
_this._tag = 'BooleanType';

@@ -300,3 +300,3 @@ return _this;

function AnyArrayType() {
var _this = _super.call(this, 'Array', Array.isArray, function (m, c) { return (_this.is(m) ? exports.success(m) : exports.failure(m, c)); }, exports.identity) || this;
var _this = _super.call(this, 'Array', Array.isArray, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this;
_this._tag = 'AnyArrayType';

@@ -316,3 +316,3 @@ return _this;

function AnyDictionaryType() {
var _this = _super.call(this, 'Dictionary', function (m) { return m !== null && typeof m === 'object'; }, function (m, c) { return (_this.is(m) ? exports.success(m) : exports.failure(m, c)); }, exports.identity) || this;
var _this = _super.call(this, 'Dictionary', function (u) { return u !== null && typeof u === 'object'; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this;
_this._tag = 'AnyDictionaryType';

@@ -353,3 +353,3 @@ return _this;

// tslint:disable-next-line:strict-type-predicates
function (m) { return typeof m === 'function'; }, function (m, c) { return (_this.is(m) ? exports.success(m) : exports.failure(m, c)); }, exports.identity) || this;
function (u) { return typeof u === 'function'; }, function (u, c) { return (_this.is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity) || this;
_this._tag = 'FunctionType';

@@ -385,3 +385,3 @@ return _this;

if (name === void 0) { name = "(" + type.name + " | " + exports.getFunctionName(predicate) + ")"; }
return new RefinementType(name, function (m) { return type.is(m) && predicate(m); }, function (i, c) {
return new RefinementType(name, function (u) { return type.is(u) && predicate(u); }, function (i, c) {
var validation = type.validate(i, c);

@@ -420,4 +420,4 @@ if (validation.isLeft()) {

if (name === void 0) { name = JSON.stringify(value); }
var is = function (m) { return m === value; };
return new LiteralType(name, is, function (m, c) { return (is(m) ? exports.success(value) : exports.failure(m, c)); }, exports.identity, value);
var is = function (u) { return u === value; };
return new LiteralType(name, is, function (u, c) { return (is(u) ? exports.success(value) : exports.failure(u, c)); }, exports.identity, value);
};

@@ -444,4 +444,4 @@ /**

if (name === void 0) { name = "(keyof " + JSON.stringify(Object.keys(keys)) + ")"; }
var is = function (m) { return exports.string.is(m) && hasOwnProperty.call(keys, m); };
return new KeyofType(name, is, function (m, c) { return (is(m) ? exports.success(m) : exports.failure(m, c)); }, exports.identity, keys);
var is = function (u) { return exports.string.is(u) && hasOwnProperty.call(keys, u); };
return new KeyofType(name, is, function (u, c) { return (is(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity, keys);
};

@@ -480,3 +480,3 @@ /**

};
var Self = new RecursiveType(name, function (m) { return runDefinition().is(m); }, function (m, c) { return runDefinition().validate(m, c); }, function (a) { return runDefinition().encode(a); }, runDefinition);
var Self = new RecursiveType(name, function (u) { return runDefinition().is(u); }, function (u, c) { return runDefinition().validate(u, c); }, function (a) { return runDefinition().encode(a); }, runDefinition);
return Self;

@@ -503,4 +503,4 @@ };

if (name === void 0) { name = "Array<" + type.name + ">"; }
return new ArrayType(name, function (m) { return arrayType.is(m) && m.every(type.is); }, function (m, c) {
var arrayValidation = arrayType.validate(m, c);
return new ArrayType(name, function (u) { return arrayType.is(u) && u.every(type.is); }, function (u, c) {
var arrayValidation = arrayType.validate(u, c);
if (arrayValidation.isLeft()) {

@@ -570,4 +570,4 @@ return arrayValidation;

var len = keys.length;
return new InterfaceType(name, function (m) {
if (!exports.Dictionary.is(m)) {
return new InterfaceType(name, function (u) {
if (!exports.Dictionary.is(u)) {
return false;

@@ -577,3 +577,3 @@ }

var k = keys[i];
if (!hasOwnProperty.call(m, k) || !types[i].is(m[k])) {
if (!hasOwnProperty.call(u, k) || !types[i].is(u[k])) {
return false;

@@ -583,4 +583,4 @@ }

return true;
}, function (m, c) {
var dictionaryValidation = exports.Dictionary.validate(m, c);
}, function (u, c) {
var dictionaryValidation = exports.Dictionary.validate(u, c);
if (dictionaryValidation.isLeft()) {

@@ -661,4 +661,4 @@ return dictionaryValidation;

}
return new PartialType(name, function (m) {
if (!exports.Dictionary.is(m)) {
return new PartialType(name, function (u) {
if (!exports.Dictionary.is(u)) {
return false;

@@ -668,3 +668,3 @@ }

var k = keys[i];
if (!partials[k].is(m[k])) {
if (!partials[k].is(u[k])) {
return false;

@@ -674,4 +674,4 @@ }

return true;
}, function (m, c) {
var dictionaryValidation = exports.Dictionary.validate(m, c);
}, function (u, c) {
var dictionaryValidation = exports.Dictionary.validate(u, c);
if (dictionaryValidation.isLeft()) {

@@ -742,4 +742,6 @@ return dictionaryValidation;

var D = isIndexSignatureRequired ? refinedDictionary : exports.Dictionary;
return new DictionaryType(name, function (m) { return D.is(m) && Object.keys(m).every(function (k) { return domain.is(k) && codomain.is(m[k]); }); }, function (m, c) {
var dictionaryValidation = D.validate(m, c);
return new DictionaryType(name, function (u) {
return D.is(u) && Object.keys(u).every(function (k) { return domain.is(k) && codomain.is(u[k]); });
}, function (u, c) {
var dictionaryValidation = D.validate(u, c);
if (dictionaryValidation.isLeft()) {

@@ -812,7 +814,7 @@ return dictionaryValidation;

var len = types.length;
return new UnionType(name, function (m) { return types.some(function (type) { return type.is(m); }); }, function (m, c) {
return new UnionType(name, function (u) { return types.some(function (type) { return type.is(u); }); }, function (u, c) {
var errors = [];
for (var i = 0; i < len; i++) {
var type_3 = types[i];
var validation = type_3.validate(m, exports.appendContext(c, String(i), type_3));
var validation = type_3.validate(u, exports.appendContext(c, String(i), type_3));
if (validation.isRight()) {

@@ -825,3 +827,3 @@ return validation;

}
return errors.length ? exports.failures(errors) : exports.failure(m, c);
return errors.length ? exports.failures(errors) : exports.failure(u, c);
}, useIdentity(types, len)

@@ -857,4 +859,4 @@ ? exports.identity

var len = types.length;
return new IntersectionType(name, function (m) { return (len === 0 ? false : types.every(function (type) { return type.is(m); })); }, function (m, c) {
var a = m;
return new IntersectionType(name, function (u) { return (len === 0 ? false : types.every(function (type) { return type.is(u); })); }, function (u, c) {
var a = u;
var errors = [];

@@ -871,3 +873,3 @@ for (var i = 0; i < len; i++) {

}
return errors.length ? exports.failures(errors) : len === 0 ? exports.failure(m, c) : exports.success(a);
return errors.length ? exports.failures(errors) : len === 0 ? exports.failure(u, c) : exports.success(a);
}, useIdentity(types, len)

@@ -902,4 +904,4 @@ ? exports.identity

var len = types.length;
return new TupleType(name, function (m) { return arrayType.is(m) && m.length === len && types.every(function (type, i) { return type.is(m[i]); }); }, function (m, c) {
var arrayValidation = arrayType.validate(m, c);
return new TupleType(name, function (u) { return arrayType.is(u) && u.length === len && types.every(function (type, i) { return type.is(u[i]); }); }, function (u, c) {
var arrayValidation = arrayType.validate(u, c);
if (arrayValidation.isLeft()) {

@@ -957,4 +959,4 @@ return arrayValidation;

if (name === void 0) { name = "Readonly<" + type.name + ">"; }
return new ReadonlyType(name, type.is, function (m, c) {
return type.validate(m, c).map(function (x) {
return new ReadonlyType(name, type.is, function (u, c) {
return type.validate(u, c).map(function (x) {
if (process.env.NODE_ENV !== 'production') {

@@ -987,4 +989,4 @@ return Object.freeze(x);

var arrayType = exports.array(type);
return new ReadonlyArrayType(name, arrayType.is, function (m, c) {
return arrayType.validate(m, c).map(function (x) {
return new ReadonlyArrayType(name, arrayType.is, function (u, c) {
return arrayType.validate(u, c).map(function (x) {
if (process.env.NODE_ENV !== 'production') {

@@ -1110,4 +1112,4 @@ return Object.freeze(x);

var isTagValue = useHash
? function (m) { return exports.string.is(m) && hasOwnProperty.call(hash, m); }
: function (m) { return values.indexOf(m) !== -1; };
? function (u) { return exports.string.is(u) && hasOwnProperty.call(hash, u); }
: function (u) { return values.indexOf(u) !== -1; };
var getIndex = useHash

@@ -1124,3 +1126,3 @@ ? function (tag) { return hash[tag]; }

};
var TagValue = new Type(values.map(function (l) { return JSON.stringify(l); }).join(' | '), isTagValue, function (m, c) { return (isTagValue(m) ? exports.success(m) : exports.failure(m, c)); }, exports.identity);
var TagValue = new Type(values.map(function (l) { return JSON.stringify(l); }).join(' | '), isTagValue, function (u, c) { return (isTagValue(u) ? exports.success(u) : exports.failure(u, c)); }, exports.identity);
return new TaggedUnionType(name, function (v) {

@@ -1184,4 +1186,4 @@ if (!exports.Dictionary.is(v)) {

var props = getProps(type);
return new ExactType(name, function (m) { return type.is(m) && Object.getOwnPropertyNames(m).every(function (k) { return hasOwnProperty.call(props, k); }); }, function (m, c) {
var looseValidation = type.validate(m, c);
return new ExactType(name, function (u) { return type.is(u) && Object.getOwnPropertyNames(u).every(function (k) { return hasOwnProperty.call(props, k); }); }, function (u, c) {
var looseValidation = type.validate(u, c);
if (looseValidation.isLeft()) {

@@ -1188,0 +1190,0 @@ return looseValidation;

{
"name": "io-ts",
"version": "1.5.3",
"version": "1.6.0",
"description": "TypeScript compatible runtime type system for IO validation",

@@ -5,0 +5,0 @@ "files": [

@@ -85,3 +85,7 @@ [![build status](https://img.shields.io/travis/gcanti/io-ts/master.svg?style=flat-square)](https://travis-ci.org/gcanti/io-ts)

The stable version is tested against TypeScript 3.2.2, but should run with TypeScript 2.7.2+ too
| io-ts version | required TypeScript version |
| ------------- | --------------------------- |
| 1.6.x | 3.2.2+ |
| 1.5.3 | 3.0.1+ |
| 1.5.2- | 2.7.2+ |

@@ -88,0 +92,0 @@ **Note**. If you are running `< typescript@3.0.1` you have to polyfill `unknown`.

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