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 0.0.3 to 0.1.0

CHANGELOG.md

85

lib/index.d.ts

@@ -1,2 +0,2 @@

import * as either from './Either';
import { Either } from 'fp-ts/lib/Either';
export interface ContextEntry {

@@ -11,3 +11,3 @@ readonly key: string;

}
export declare type Validation<T> = either.Either<Array<ValidationError>, T>;
export declare type Validation<T> = Either<Array<ValidationError>, T>;
export declare type Validate<T> = (value: any, context: Context) => Validation<T>;

@@ -21,10 +21,8 @@ export declare type Any = Type<any>;

constructor(name: string, validate: Validate<T>);
is(x: any): x is T;
}
export declare function getFunctionName(f: any): string;
export declare function isSuccess<T>(validation: Validation<T>): boolean;
export declare function isFailure<T>(validation: Validation<T>): boolean;
export declare function failure<T>(value: any, context: Context): Validation<T>;
export declare function success<T>(value: T): Validation<T>;
export declare function validate<T>(value: any, type: Type<T>): Validation<T>;
export declare function fromValidation<T>(value: any, type: Type<T>): T;
export declare class LiteralType<T> extends Type<T> {

@@ -35,7 +33,11 @@ readonly value: T;

export declare function literal<T extends string | number | boolean>(value: T): LiteralType<T>;
export declare class InstanceOfType<T extends Function> extends Type<T> {
readonly ctor: T;
constructor(name: string, validate: Validate<T>, ctor: T);
export declare class KeyofType<D extends {
[key: string]: any;
}> extends Type<keyof D> {
readonly map: D;
constructor(name: string, validate: Validate<keyof D>, map: D);
}
export declare function instanceOf<T extends Function>(ctor: T, name?: string): InstanceOfType<T>;
export declare function keyof<D extends {
[key: string]: any;
}>(map: D, name?: string): KeyofType<D>;
declare const nullType: Type<null>;

@@ -48,3 +50,3 @@ declare const undefinedType: Type<undefined>;

declare const arrayType: Type<Array<any>>;
declare const objectType: Type<{
export declare const Dictionary: Type<{
[key: string]: any;

@@ -60,2 +62,3 @@ }>;

export declare function refinement<RT extends Any>(type: RT, predicate: Predicate<TypeOf<RT>>, name?: string): RefinementType<RT>;
export declare const Integer: RefinementType<Type<number>>;
export declare function recursion<T>(name: string, definition: (self: Any) => Any): Type<T>;

@@ -75,3 +78,3 @@ export declare class MaybeType<RT extends Any> extends Type<TypeOf<RT> | undefined | null> {

};
export declare class ObjectType<P extends Props> extends Type<{
export declare class InterfaceType<P extends Props> extends Type<{
[K in keyof P]: TypeOf<P[K]>;

@@ -84,4 +87,4 @@ }> {

}
export declare function object<P extends Props>(props: P, name?: string): ObjectType<P>;
export declare class MappingType<D extends Type<string>, C extends Any> extends Type<{
declare function interfaceType<P extends Props>(props: P, name?: string): InterfaceType<P>;
export declare class DictionaryType<D extends Type<string>, C extends Any> extends Type<{
[key: string]: TypeOf<C>;

@@ -95,3 +98,3 @@ }> {

}
export declare function mapping<D extends Type<string>, C extends Any>(domain: D, codomain: C, name?: string): MappingType<D, C>;
export declare function dictionary<D extends Type<string>, C extends Any>(domain: D, codomain: C, name?: string): DictionaryType<D, C>;
export declare class UnionType<RTS, U> extends Type<U> {

@@ -131,28 +134,28 @@ readonly types: RTS;

}
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any, W extends Any, X extends Any, Y extends Any, Z extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X> & TypeOf<Y> & TypeOf<Z>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any, W extends Any, X extends Any, Y extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X> & TypeOf<Y>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any, W extends Any, X extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any, W extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any>(types: [A, B, C, D, E, F, G, H, I, J], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any>(types: [A, B, C, D, E, F, G, H, I], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any>(types: [A, B, C, D, E, F, G, H], name?: string): IntersectionType<[A, B, C, D, E, F, G, H], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any>(types: [A, B, C, D, E, F, G], name?: string): IntersectionType<[A, B, C, D, E, F, G], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any>(types: [A, B, C, D, E, F], name?: string): IntersectionType<[A, B, C, D, E, F], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any>(types: [A, B, C, D, E], name?: string): IntersectionType<[A, B, C, D, E], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any>(types: [A, B, C, D], name?: string): IntersectionType<[A, B, C, D], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D>>;
export declare function intersection<A extends Any, B extends Any, C extends Any>(types: [A, B, C], name?: string): IntersectionType<[A, B, C], TypeOf<A> & TypeOf<B> & TypeOf<C>>;
export declare function intersection<A extends Any, B extends Any>(types: [A, B], name?: string): IntersectionType<[A, B], TypeOf<A> & TypeOf<B>>;
export declare function intersection<A extends Any>(types: [A], name?: string): IntersectionType<[A], TypeOf<A>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>, W extends InterfaceType<any>, X extends InterfaceType<any>, Y extends InterfaceType<any>, Z extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X> & TypeOf<Y> & TypeOf<Z>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>, W extends InterfaceType<any>, X extends InterfaceType<any>, Y extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X> & TypeOf<Y>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>, W extends InterfaceType<any>, X extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>, W extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H], name?: string): IntersectionType<[A, B, C, D, E, F, G, H], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>>(types: [A, B, C, D, E, F, G], name?: string): IntersectionType<[A, B, C, D, E, F, G], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>>(types: [A, B, C, D, E, F], name?: string): IntersectionType<[A, B, C, D, E, F], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>>(types: [A, B, C, D, E], name?: string): IntersectionType<[A, B, C, D, E], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>>(types: [A, B, C, D], name?: string): IntersectionType<[A, B, C, D], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>>(types: [A, B, C], name?: string): IntersectionType<[A, B, C], TypeOf<A> & TypeOf<B> & TypeOf<C>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>>(types: [A, B], name?: string): IntersectionType<[A, B], TypeOf<A> & TypeOf<B>>;
export declare function intersection<A extends InterfaceType<any>>(types: [A], name?: string): IntersectionType<[A], TypeOf<A>>;
export declare class TupleType<RTS, T> extends Type<T> {

@@ -188,2 +191,2 @@ readonly types: RTS;

export declare function tuple<A extends Any>(types: [A], name?: string): TupleType<[A], [TypeOf<A>]>;
export { nullType as null, undefinedType as undefined, arrayType as Array, objectType as Object, functionType as Function };
export { nullType as null, undefinedType as undefined, arrayType as Array, functionType as Function, interfaceType as interface };

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

};
var either = require("./Either");
var Either_1 = require("fp-ts/lib/Either");
;

@@ -24,2 +24,5 @@ ;

}
Type.prototype.is = function (x) {
return Either_1.isRight(validate(x, this));
};
return Type;

@@ -38,10 +41,2 @@ }());

}
function isSuccess(validation) {
return validation instanceof either.Right;
}
exports.isSuccess = isSuccess;
function isFailure(validation) {
return validation instanceof either.Left;
}
exports.isFailure = isFailure;
function getValidationError(value, context) {

@@ -53,11 +48,16 @@ return { value: value, context: context };

}
function failures(errors) {
return new either.Left(errors);
function hasExcessProps(props, o) {
for (var k in o) {
if (!props.hasOwnProperty(k)) {
return true;
}
}
return false;
}
function failure(value, context) {
return new either.Left([getValidationError(value, context)]);
return new Either_1.Left([getValidationError(value, context)]);
}
exports.failure = failure;
function success(value) {
return new either.Right(value);
return new Either_1.Right(value);
}

@@ -72,6 +72,2 @@ exports.success = success;

exports.validate = validate;
function fromValidation(value, type) {
return validate(value, type).fold(function () { throw new Error(); }, either.identity);
}
exports.fromValidation = fromValidation;
//

@@ -95,20 +91,20 @@ // literal types

//
// class instances
// keyof types
//
var InstanceOfType = (function (_super) {
__extends(InstanceOfType, _super);
function InstanceOfType(name, validate, ctor) {
var KeyofType = (function (_super) {
__extends(KeyofType, _super);
function KeyofType(name, validate, map) {
var _this = _super.call(this, name, validate) || this;
_this.ctor = ctor;
_this.map = map;
return _this;
}
return InstanceOfType;
return KeyofType;
}(Type));
exports.InstanceOfType = InstanceOfType;
function instanceOf(ctor, name) {
return new InstanceOfType(name || getFunctionName(ctor), function (v, c) { return v instanceof ctor ? success(v) : failure(v, c); }, ctor);
exports.KeyofType = KeyofType;
function keyof(map, name) {
return new KeyofType(name || "(keyof " + JSON.stringify(Object.keys(map)) + ")", function (v, c) { return map.hasOwnProperty(v) ? success(v) : failure(v, c); }, map);
}
exports.instanceOf = instanceOf;
exports.keyof = keyof;
//
// default irreducibles
// default types
//

@@ -122,3 +118,3 @@ function isNil(v) {

exports.undefined = undefinedType;
exports.any = new Type('any', function (v, c) { return success(v); });
exports.any = new Type('any', function (v, _) { return success(v); });
exports.string = new Type('string', function (v, c) { return typeof v === 'string' ? success(v) : failure(v, c); });

@@ -129,4 +125,3 @@ exports.number = new Type('number', function (v, c) { return typeof v === 'number' ? success(v) : failure(v, c); });

exports.Array = arrayType;
var objectType = new Type('Object', function (v, c) { return !isNil(v) && typeof v === 'object' && !Array.isArray(v) ? success(v) : failure(v, c); });
exports.Object = objectType;
exports.Dictionary = new Type('Dictionary', function (v, c) { return v !== null && typeof v === 'object' ? success(v) : failure(v, c); });
var functionType = new Type('Function', function (v, c) { return typeof v === 'function' ? success(v) : failure(v, c); });

@@ -149,2 +144,3 @@ exports.Function = functionType;

exports.refinement = refinement;
exports.Integer = refinement(exports.number, function (n) { return n % 1 === 0; }, 'Integer');
//

@@ -206,9 +202,9 @@ // recursive types

}
return errors.length ? failures(errors) : success(changed ? t : as);
return errors.length ? new Either_1.Left(errors) : success(changed ? t : as);
}); }, type);
}
exports.array = array;
var ObjectType = (function (_super) {
__extends(ObjectType, _super);
function ObjectType(name, validate, props) {
var InterfaceType = (function (_super) {
__extends(InterfaceType, _super);
function InterfaceType(name, validate, props) {
var _this = _super.call(this, name, validate) || this;

@@ -218,8 +214,8 @@ _this.props = props;

}
return ObjectType;
return InterfaceType;
}(Type));
exports.ObjectType = ObjectType;
function object(props, name) {
return new ObjectType(name || "{ " + Object.keys(props).map(function (k) { return k + ": " + props[k].name; }).join(', ') + " }", function (v, c) { return objectType.validate(v, c).chain(function (o) {
var t = __assign({}, o);
exports.InterfaceType = InterfaceType;
function interfaceType(props, name) {
return new InterfaceType(name || "{ " + Object.keys(props).map(function (k) { return k + ": " + props[k].name; }).join(', ') + " }", function (v, c) { return exports.Dictionary.validate(v, c).chain(function (o) {
var t = {};
var errors = [];

@@ -239,12 +235,15 @@ var changed = false;

}
return errors.length ? failures(errors) : success((changed ? t : o));
if (!changed) {
changed = hasExcessProps(props, o);
}
return errors.length ? new Either_1.Left(errors) : success((changed ? t : o));
}); }, props);
}
exports.object = object;
exports.interface = interfaceType;
//
// mappings
// dictionaries
//
var MappingType = (function (_super) {
__extends(MappingType, _super);
function MappingType(name, validate, domain, codomain) {
var DictionaryType = (function (_super) {
__extends(DictionaryType, _super);
function DictionaryType(name, validate, domain, codomain) {
var _this = _super.call(this, name, validate) || this;

@@ -255,7 +254,7 @@ _this.domain = domain;

}
return MappingType;
return DictionaryType;
}(Type));
exports.MappingType = MappingType;
function mapping(domain, codomain, name) {
return new MappingType(name || "{ [key: " + getTypeName(domain) + "]: " + getTypeName(codomain) + " }", function (v, c) { return objectType.validate(v, c).chain(function (o) {
exports.DictionaryType = DictionaryType;
function dictionary(domain, codomain, name) {
return new DictionaryType(name || "{ [key: " + getTypeName(domain) + "]: " + getTypeName(codomain) + " }", function (v, c) { return exports.Dictionary.validate(v, c).chain(function (o) {
var t = {};

@@ -280,6 +279,6 @@ var errors = [];

}
return errors.length ? failures(errors) : success((changed ? t : o));
return errors.length ? new Either_1.Left(errors) : success((changed ? t : o));
}); }, domain, codomain);
}
exports.mapping = mapping;
exports.dictionary = dictionary;
//

@@ -302,3 +301,3 @@ // unions

var validation = types[i].validate(v, c);
if (isSuccess(validation)) {
if (Either_1.isRight(validation)) {
return validation;

@@ -325,16 +324,6 @@ }

function intersection(types, name) {
return new IntersectionType(name || "(" + types.map(getTypeName).join(' & ') + ")", function (v, c) {
var t = v;
var changed = false;
var errors = [];
for (var i = 0, len = types.length; i < len; i++) {
var type = types[i];
var validation = type.validate(t, c.concat(getContextEntry(String(i), type)));
validation.fold(function (error) { return pushAll(errors, error); }, function (vv) {
changed = changed || (vv !== t);
t = vv;
});
}
return errors.length ? failures(errors) : success(changed ? t : v);
}, types);
var displayName = name || "(" + types.map(getTypeName).join(' & ') + ")";
var props = types.reduce(function (acc, x) { return (__assign({}, acc, x.props)); }, {});
var type = interfaceType(props, displayName);
return new IntersectionType(displayName, type.validate, types);
}

@@ -372,5 +361,6 @@ exports.intersection = intersection;

}
return errors.length ? failures(errors) : success(changed ? t : as);
return errors.length ? new Either_1.Left(errors) : success(changed ? t : as);
}); }, types);
}
exports.tuple = tuple;
//# sourceMappingURL=index.js.map
"use strict";
var Either_1 = require("fp-ts/lib/Either");
var index_1 = require("../index");

@@ -17,3 +18,3 @@ function stringify(value) {

report: function (validation) {
if (index_1.isFailure(validation)) {
if (Either_1.isLeft(validation)) {
throw exports.PathReporter.report(validation).join('\n');

@@ -23,1 +24,2 @@ }

};
//# sourceMappingURL=default.js.map
"use strict";
//# sourceMappingURL=Reporter.js.map
{
"name": "io-ts",
"version": "0.0.3",
"version": "0.1.0",
"description": "TypeScript compatible runtime type system for IO validation",
"files": [
"lib"
"lib",
"lib-jsnext"
],
"main": "lib/index.js",
"jsnext:main": "lib-jsnext/index.js",
"typings": "lib/index.d.ts",
"scripts": {
"test": "mocha -r ts-node/register test/*.ts",
"build": "rm -rf lib/* && tsc -d"
"build": "rm -rf lib/* && rm -rf lib-jsnext/* && tsc && tsc -m es6 --outDir lib-jsnext"
},

@@ -25,2 +27,3 @@ "repository": {

"dependencies": {
"fp-ts": "^0.0.2"
},

@@ -32,3 +35,3 @@ "devDependencies": {

"ts-node": "^2.0.0",
"typescript": "^2.1.5"
"typescript": "^2.2.0"
},

@@ -35,0 +38,0 @@ "tags": [

@@ -8,2 +8,3 @@ # The idea

constructor(public readonly name: string, public readonly validate: Validate<T>) {}
is(x: any): x is T
}

@@ -23,2 +24,3 @@ ```

```js
import { Right, Left } from 'fp-ts/lib/Either'
import * as t from 'io-ts'

@@ -35,3 +37,3 @@

```js
const Person = t.object({
const Person = t.interface({
name: t.string,

@@ -128,16 +130,18 @@ age: t.number

| number | `number` | `t.number` |
| integer | ✘ | `t.Integer` |
| boolean | `boolean` | `t.boolean` |
| generic array | `Array<any>` | `t.Array` |
| generic object | `Object` | `t.Object` |
| generic function | `Function` | `t.Function` |
| generic dictionary | `{ [key: string]: any }` | `t.Dictionary` |
| function | `Function` | `t.Function` |
| instance of `C` | `C` | `t.instanceOf(C)` |
| list | `Array<A>` | `t.array(A)` |
| arrays | `Array<A>` | `t.array(A)` |
| literal | `'s'` | `t.literal('s')` |
| maybe | `A | undefined | null` | `t.maybe(A)` |
| mapping | `{ [key: A]: B }` | `t.mapping(A, B)` |
| dictionaries | `{ [key: A]: B }` | `t.dictionary(A, B)` |
| refinement | ✘ | `t.refinement(A, predicate)` |
| object | `{ name: string }` | `t.object({ name: t.string })` |
| interface | `{ name: string }` | `t.interface({ name: t.string })` |
| tuple | `[A, B]` | `t.tuple([A, B])` |
| union | `A | B` | `t.union([A, B])` |
| intersection | `A & B` | `t.intersection([A, B])` |
| keyof | `keyof M` | `t.keyof(M)` |
| recursive types | | `t.recursion(name, definition)` |
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