Socket
Socket
Sign inDemoInstall

io-ts

Package Overview
Dependencies
1
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.9.0 to 0.9.1-dev.20171201

74

lib/index.d.ts

@@ -107,14 +107,14 @@ import { Either } from 'fp-ts/lib/Either';

export declare const Function: FunctionType;
export declare class RefinementType<RT extends Any> extends Type<InputOf<RT>, TypeOf<RT>> {
export declare class RefinementType<RT extends Any, S, A> extends Type<S, A> {
readonly type: RT;
readonly predicate: Predicate<TypeOf<RT>>;
readonly predicate: Predicate<A>;
readonly _tag: 'RefinementType';
constructor(name: string, type: RT, predicate: Predicate<TypeOf<RT>>);
constructor(name: string, is: RefinementType<RT, S, A>['is'], validate: RefinementType<RT, S, A>['validate'], serialize: RefinementType<RT, S, A>['serialize'], type: RT, predicate: Predicate<A>);
}
export declare const refinement: <RT extends Type<any, any>>(type: RT, predicate: Predicate<RT["_A"]>, name?: string) => RefinementType<RT>;
export declare const Integer: RefinementType<NumberType>;
export declare const refinement: <RT extends Type<any, any>>(type: RT, predicate: Predicate<RT["_A"]>, name?: string) => RefinementType<RT, RT["_S"], RT["_A"]>;
export declare const Integer: RefinementType<NumberType, any, number>;
export declare class LiteralType<V extends string | number | boolean> extends Type<any, V> {
readonly value: V;
readonly _tag: 'LiteralType';
constructor(name: string, value: V);
constructor(name: string, is: LiteralType<V>['is'], validate: LiteralType<V>['validate'], serialize: LiteralType<V>['serialize'], value: V);
}

@@ -127,3 +127,3 @@ export declare const literal: <V extends string | number | boolean>(value: V, name?: string) => LiteralType<V>;

readonly _tag: 'KeyofType';
constructor(name: string, keys: D);
constructor(name: string, is: KeyofType<D>['is'], validate: KeyofType<D>['validate'], serialize: KeyofType<D>['serialize'], keys: D);
}

@@ -133,14 +133,14 @@ export declare const keyof: <D extends {

}>(keys: D, name?: string) => KeyofType<D>;
export declare class RecursiveType<A> extends Type<any, A> {
export declare class RecursiveType<RT extends Any, A> extends Type<any, A> {
readonly _tag: 'RecursiveType';
readonly 'type': Any;
constructor(name: string, is: Is<A>, validate: Validate<any, A>, serialize: Serialize<any, A>);
readonly 'type': RT;
constructor(name: string, is: RecursiveType<RT, A>['is'], validate: RecursiveType<RT, A>['validate'], serialize: RecursiveType<RT, A>['serialize']);
}
export declare const recursion: <A>(name: string, definition: (self: Type<any, any>) => Type<any, any>) => RecursiveType<A>;
export declare class ArrayType<RT extends Any> extends Type<any, Array<TypeOf<RT>>> {
export declare const recursion: <A, RT extends Type<any, any> = Type<any, any>>(name: string, definition: (self: RT) => RT) => RecursiveType<RT, A>;
export declare class ArrayType<RT extends Any, A> extends Type<any, A> {
readonly type: RT;
readonly _tag: 'ArrayType';
constructor(name: string, is: ArrayType<RT>['is'], validate: ArrayType<RT>['validate'], serialize: ArrayType<RT>['serialize'], type: RT);
constructor(name: string, is: ArrayType<RT, A>['is'], validate: ArrayType<RT, A>['validate'], serialize: ArrayType<RT, A>['serialize'], type: RT);
}
export declare const array: <RT extends Type<any, any>>(type: RT, name?: string) => ArrayType<RT>;
export declare const array: <RT extends Type<any, any>>(type: RT, name?: string) => ArrayType<RT, RT["_A"][]>;
export declare type Props = {

@@ -152,28 +152,28 @@ [key: string]: Any;

};
export declare class InterfaceType<P extends Props> extends Type<any, InterfaceOf<P>> {
export declare class InterfaceType<P extends Props, A> extends Type<any, A> {
readonly props: P;
readonly _tag: 'InterfaceType';
constructor(name: string, is: InterfaceType<P>['is'], validate: InterfaceType<P>['validate'], serialize: InterfaceType<P>['serialize'], props: P);
constructor(name: string, is: InterfaceType<P, A>['is'], validate: InterfaceType<P, A>['validate'], serialize: InterfaceType<P, A>['serialize'], props: P);
}
/** @alias `interface` */
export declare const type: <P extends Props>(props: P, name?: string) => InterfaceType<P>;
export declare const type: <P extends Props>(props: P, name?: string) => InterfaceType<P, InterfaceOf<P>>;
export declare type PartialOf<P extends Props> = {
[K in keyof P]?: TypeOf<P[K]>;
};
export declare class PartialType<P extends Props> extends Type<any, PartialOf<P>> {
export declare class PartialType<P extends Props, A> extends Type<any, A> {
readonly props: P;
readonly _tag: 'PartialType';
constructor(name: string, is: PartialType<P>['is'], validate: PartialType<P>['validate'], serialize: PartialType<P>['serialize'], props: P);
constructor(name: string, is: PartialType<P, A>['is'], validate: PartialType<P, A>['validate'], serialize: PartialType<P, A>['serialize'], props: P);
}
export declare const partial: <P extends Props>(props: P, name?: string) => PartialType<P>;
export declare class DictionaryType<D extends Any, C extends Any> extends Type<any, {
[K in TypeOf<D>]: TypeOf<C>;
}> {
export declare const partial: <P extends Props>(props: P, name?: string) => PartialType<P, PartialOf<P>>;
export declare class DictionaryType<D extends Any, C extends Any, A> extends Type<any, A> {
readonly domain: D;
readonly codomain: C;
readonly _tag: 'DictionaryType';
constructor(name: string, is: DictionaryType<D, C>['is'], validate: DictionaryType<D, C>['validate'], serialize: DictionaryType<D, C>['serialize'], domain: D, codomain: C);
constructor(name: string, is: DictionaryType<D, C, A>['is'], validate: DictionaryType<D, C, A>['validate'], serialize: DictionaryType<D, C, A>['serialize'], domain: D, codomain: C);
}
export declare const dictionary: <D extends Type<any, any>, C extends Type<any, any>>(domain: D, codomain: C, name?: string) => DictionaryType<D, C>;
export declare class UnionType<RTS, A> extends Type<any, A> {
export declare const dictionary: <D extends Type<any, any>, C extends Type<any, any>>(domain: D, codomain: C, name?: string) => DictionaryType<D, C, {
[K in D["_A"]]: C["_A"];
}>;
export declare class UnionType<RTS extends Array<Any>, A> extends Type<any, A> {
readonly types: RTS;

@@ -184,3 +184,3 @@ readonly _tag: 'UnionType';

export declare const union: <RTS extends Type<any, any>[]>(types: RTS, name?: string) => UnionType<RTS, RTS["_A"]["_A"]>;
export declare class IntersectionType<RTS, A> extends Type<any, A> {
export declare class IntersectionType<RTS extends Array<Any>, A> extends Type<any, A> {
readonly types: RTS;

@@ -195,3 +195,3 @@ readonly _tag: 'IntersectionType';

export declare function intersection<A extends Any>(types: [A], name?: string): IntersectionType<[A], TypeOf<A>>;
export declare class TupleType<RTS, A> extends Type<any, A> {
export declare class TupleType<RTS extends Array<Any>, A> extends Type<any, A> {
readonly types: RTS;

@@ -206,21 +206,21 @@ readonly _tag: 'TupleType';

export declare function tuple<A extends Any>(types: [A], name?: string): TupleType<[A], [TypeOf<A>]>;
export declare class ReadonlyType<RT extends Any> extends Type<any, Readonly<TypeOf<RT>>> {
export declare class ReadonlyType<RT extends Any, A> extends Type<any, A> {
readonly type: RT;
readonly _tag: 'ReadonlyType';
constructor(name: string, is: ReadonlyType<RT>['is'], validate: ReadonlyType<RT>['validate'], serialize: ReadonlyType<RT>['serialize'], type: RT);
constructor(name: string, is: ReadonlyType<RT, A>['is'], validate: ReadonlyType<RT, A>['validate'], serialize: ReadonlyType<RT, A>['serialize'], type: RT);
}
export declare const readonly: <RT extends Type<any, any>>(type: RT, name?: string) => ReadonlyType<RT>;
export declare class ReadonlyArrayType<RT extends Any> extends Type<any, ReadonlyArray<TypeOf<RT>>> {
export declare const readonly: <RT extends Type<any, any>>(type: RT, name?: string) => ReadonlyType<RT, Readonly<RT["_A"]>>;
export declare class ReadonlyArrayType<RT extends Any, A> extends Type<any, A> {
readonly type: RT;
readonly _tag: 'ReadonlyArrayType';
constructor(name: string, is: ReadonlyArrayType<RT>['is'], validate: ReadonlyArrayType<RT>['validate'], serialize: ReadonlyArrayType<RT>['serialize'], type: RT);
constructor(name: string, is: ReadonlyArrayType<RT, A>['is'], validate: ReadonlyArrayType<RT, A>['validate'], serialize: ReadonlyArrayType<RT, A>['serialize'], type: RT);
}
export declare const readonlyArray: <RT extends Type<any, any>>(type: RT, name?: string) => ReadonlyArrayType<RT>;
export declare class StrictType<P extends Props> extends Type<any, InterfaceOf<P>> {
export declare const readonlyArray: <RT extends Type<any, any>>(type: RT, name?: string) => ReadonlyArrayType<RT, ReadonlyArray<RT["_A"]>>;
export declare class StrictType<P extends Props, A> extends Type<any, A> {
readonly props: P;
readonly _tag: 'StrictType';
constructor(name: string, is: StrictType<P>['is'], validate: StrictType<P>['validate'], serialize: StrictType<P>['serialize'], props: P);
constructor(name: string, is: StrictType<P, A>['is'], validate: StrictType<P, A>['validate'], serialize: StrictType<P, A>['serialize'], props: P);
}
/** Specifies that only the given interface properties are allowed */
export declare const strict: <P extends Props>(props: P, name?: string) => StrictType<P>;
export declare const strict: <P extends Props>(props: P, name?: string) => StrictType<P, InterfaceOf<P>>;
export { nullType as null, undefinedType as undefined, arrayType as Array, type as interface };

@@ -192,4 +192,4 @@ "use strict";

__extends(RefinementType, _super);
function RefinementType(name, type, predicate) {
var _this = _super.call(this, name, function (v) { return type.is(v) && predicate(v); }, function (s, c) { return type.validate(s, c).chain(function (a) { return (predicate(a) ? exports.success(a) : exports.failure(a, c)); }); }, type.serialize) || this;
function RefinementType(name, is, validate, serialize, type, predicate) {
var _this = _super.call(this, name, is, validate, serialize) || this;
_this.type = type;

@@ -205,3 +205,3 @@ _this.predicate = predicate;

if (name === void 0) { name = "(" + type.name + " | " + exports.getFunctionName(predicate) + ")"; }
return new RefinementType(name, type, predicate);
return new RefinementType(name, function (v) { return type.is(v) && predicate(v); }, function (s, c) { return type.validate(s, c).chain(function (a) { return (predicate(a) ? exports.success(a) : exports.failure(a, c)); }); }, type.serialize, type, predicate);
};

@@ -214,4 +214,4 @@ exports.Integer = exports.refinement(exports.number, function (n) { return n % 1 === 0; }, 'Integer');

__extends(LiteralType, _super);
function LiteralType(name, value) {
var _this = _super.call(this, name, function (v) { return v === value; }, function (s, c) { return (_this.is(s) ? exports.success(value) : exports.failure(s, c)); }, exports.identity) || this;
function LiteralType(name, is, validate, serialize, value) {
var _this = _super.call(this, name, is, validate, serialize) || this;
_this.value = value;

@@ -226,3 +226,4 @@ _this._tag = 'LiteralType';

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

@@ -234,4 +235,4 @@ //

__extends(KeyofType, _super);
function KeyofType(name, keys) {
var _this = _super.call(this, name, function (v) { return exports.string.is(v) && keys.hasOwnProperty(v); }, function (s, c) { return (_this.is(s) ? exports.success(s) : exports.failure(s, c)); }, exports.identity) || this;
function KeyofType(name, is, validate, serialize, keys) {
var _this = _super.call(this, name, is, validate, serialize) || this;
_this.keys = keys;

@@ -246,3 +247,4 @@ _this._tag = 'KeyofType';

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

@@ -249,0 +251,0 @@ //

{
"name": "io-ts",
"version": "0.9.0",
"version": "0.9.1-dev.20171201",
"description": "TypeScript compatible runtime type system for IO validation",

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

@@ -297,4 +297,6 @@ # The idea

const { NODE_ENV } = process.env
export function unsafeValidate<S, A>(value: any, type: t.Type<S, A>): A {
if (process.env.NODE_ENV !== 'production') {
if (NODE_ENV !== 'production') {
return t.validate(value, type).fold(errors => {

@@ -301,0 +303,0 @@ throw new Error(failure(errors).join('\n'))

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc