Comparing version 0.9.7 to 0.9.8-rc
@@ -29,2 +29,3 @@ import { Either } from 'fp-ts/lib/Either'; | ||
readonly validate: Validate<S, A>; | ||
readonly decode: (s: S) => Validation<A>; | ||
} | ||
@@ -64,2 +65,4 @@ export interface Encoder<S, A> { | ||
asEncoder(): Encoder<S, A>; | ||
/** succeeds if a value of type S can be decoded to a value of type A */ | ||
decode(s: S): Validation<A>; | ||
} | ||
@@ -75,2 +78,3 @@ export declare const identity: <A>(a: A) => A; | ||
export declare const success: <T>(value: T) => Either<ValidationError[], T>; | ||
/** @deprecated use `type.decode(value)` instead */ | ||
export declare const validate: <S, A>(value: S, type: Decoder<S, A>) => Either<ValidationError[], A>; | ||
@@ -200,5 +204,3 @@ export declare class NullType extends Type<mixed, null> { | ||
} | ||
export declare const dictionary: <D extends Type<mixed, any>, C extends Type<mixed, any>>(domain: D, codomain: C, name?: string) => DictionaryType<D, C, { | ||
[K in D["_A"]]: C["_A"]; | ||
}>; | ||
export declare const dictionary: <D extends Type<mixed, any>, C extends Type<mixed, 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<mixed, A> { | ||
@@ -205,0 +207,0 @@ readonly types: RTS; |
@@ -31,10 +31,10 @@ "use strict"; | ||
function Type( | ||
/** a unique name for this runtime type */ | ||
name, | ||
/** a custom type guard */ | ||
is, | ||
/** succeeds if a value of type S can be decoded to a value of type A */ | ||
validate, | ||
/** converts a value of type A to a value of type S */ | ||
serialize) { | ||
/** a unique name for this runtime type */ | ||
name, | ||
/** a custom type guard */ | ||
is, | ||
/** succeeds if a value of type S can be decoded to a value of type A */ | ||
validate, | ||
/** converts a value of type A to a value of type S */ | ||
serialize) { | ||
this.name = name; | ||
@@ -57,2 +57,6 @@ this.is = is; | ||
}; | ||
/** succeeds if a value of type S can be decoded to a value of type A */ | ||
Type.prototype.decode = function (s) { | ||
return this.validate(s, exports.getDefaultContext(this)); | ||
}; | ||
return Type; | ||
@@ -82,2 +86,3 @@ }()); | ||
exports.success = function (value) { return new Either_1.Right(value); }; | ||
/** @deprecated use `type.decode(value)` instead */ | ||
exports.validate = function (value, type) { | ||
@@ -522,3 +527,3 @@ return type.validate(value, exports.getDefaultContext(type)); | ||
var validation = type_2.validate(s, exports.appendContext(c, String(i), type_2)); | ||
if (Either_1.isRight(validation)) { | ||
if (validation.isRight()) { | ||
return validation; | ||
@@ -525,0 +530,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Either_1 = require("fp-ts/lib/Either"); | ||
var PathReporter_1 = require("./PathReporter"); | ||
exports.ThrowReporter = { | ||
report: function (validation) { | ||
if (Either_1.isLeft(validation)) { | ||
if (validation.isLeft()) { | ||
throw PathReporter_1.PathReporter.report(validation).join('\n'); | ||
@@ -9,0 +8,0 @@ } |
{ | ||
"name": "io-ts", | ||
"version": "0.9.7", | ||
"version": "0.9.8-rc", | ||
"description": "TypeScript compatible runtime type system for IO validation", | ||
@@ -12,3 +12,3 @@ "files": ["lib"], | ||
"typings-checker --allow-expect-error --project typings-checker/tsconfig.json typings-checker/index.ts", | ||
"mocha": "mocha -r ts-node/register test/*.ts", | ||
"mocha": "TS_NODE_CACHE=false mocha -r ts-node/register test/*.ts", | ||
"prettier": | ||
@@ -38,3 +38,3 @@ "prettier --no-semi --single-quote --print-width 120 --parser typescript --list-different \"{src,test}/**/*.ts\"", | ||
"dependencies": { | ||
"fp-ts": "^0.6.4" | ||
"fp-ts": "^1.0.0-rc" | ||
}, | ||
@@ -51,3 +51,3 @@ "devDependencies": { | ||
"tslint-config-standard": "4.0.0", | ||
"typescript": "2.6.2", | ||
"typescript": "^2.7.1", | ||
"typings-checker": "1.1.2" | ||
@@ -54,0 +54,0 @@ }, |
@@ -0,1 +1,5 @@ | ||
[![build status](https://img.shields.io/travis/gcanti/io-ts/master.svg?style=flat-square)](https://travis-ci.org/gcanti/io-ts) | ||
[![dependency status](https://img.shields.io/david/gcanti/io-ts.svg?style=flat-square)](https://david-dm.org/gcanti/io-ts) | ||
![npm downloads](https://img.shields.io/npm/dm/io-ts.svg) | ||
# The idea | ||
@@ -2,0 +6,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114306
1098
409
+ Addedfp-ts@1.19.5(transitive)
- Removedfp-ts@0.6.8(transitive)
Updatedfp-ts@^1.0.0-rc