io-ts-reporters
Advanced tools
Comparing version 0.0.21 to 1.0.0
@@ -5,3 +5,3 @@ { | ||
"typings": "./target/src/index.d.ts", | ||
"version": "0.0.21", | ||
"version": "1.0.0", | ||
"scripts": { | ||
@@ -17,9 +17,9 @@ "lint": "tslint --project tsconfig.json", | ||
"dependencies": { | ||
"fp-ts": "^1.0.1", | ||
"io-ts": "^1.0.2" | ||
"fp-ts": "^2.0.2", | ||
"io-ts": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"tslint": "^5.8.0", | ||
"typescript": "^2.7.2" | ||
"typescript": "^3.5.3" | ||
} | ||
} |
@@ -9,5 +9,12 @@ # io-ts-reporters | ||
## TypeScript compatibility | ||
| io-ts-reporters version | required typescript version | | ||
| ----------------------- | --------------------------- | | ||
| 1.0.0 | 3.5+ | | ||
| <= 0.0.21 | 2.7+ | | ||
## Installation | ||
``` bash | ||
```bash | ||
yarn add io-ts-reporters | ||
@@ -22,3 +29,3 @@ ``` | ||
``` bash | ||
```bash | ||
yarn | ||
@@ -28,2 +35,2 @@ yarn run test | ||
[io-ts]: https://github.com/gcanti/io-ts#error-reporters | ||
[io-ts]: https://github.com/gcanti/io-ts#error-reporters |
import * as t from 'io-ts'; | ||
import { Left, Right } from 'fp-ts/lib/Either'; | ||
import { None, Some } from 'fp-ts/lib/Option'; | ||
export declare const formatValidationError: (error: t.ValidationError) => None<string> | Some<string>; | ||
export declare const reporter: <T>(validation: Left<t.ValidationError[], T> | Right<t.ValidationError[], T>) => string[]; | ||
export declare const formatValidationError: (error: t.ValidationError) => import("fp-ts/lib/Option").Option<string>; | ||
export declare const reporter: <T>(validation: import("fp-ts/lib/Either").Either<t.Errors, T>) => string[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var array = require("fp-ts/lib/Array"); | ||
/* tslint:enable no-unused-variable */ | ||
var Either_1 = require("fp-ts/lib/Either"); | ||
var Option_1 = require("fp-ts/lib/Option"); | ||
var pipeable_1 = require("fp-ts/lib/pipeable"); | ||
var jsToString = function (value) { return (value === undefined ? 'undefined' : JSON.stringify(value)); }; | ||
@@ -9,2 +11,4 @@ exports.formatValidationError = function (error) { | ||
.map(function (c) { return c.key; }) | ||
// The context entry with an empty key is the original type ("default | ||
// context"), not an type error. | ||
.filter(function (key) { return key.length > 0; }) | ||
@@ -16,3 +20,3 @@ .join('.'); | ||
error.context); | ||
return maybeErrorContext.map(function (errorContext) { | ||
return pipeable_1.pipe(maybeErrorContext, Option_1.map(function (errorContext) { | ||
var expectedType = errorContext.type.name; | ||
@@ -25,5 +29,5 @@ return ( | ||
+ (" but instead got: " + jsToString(error.value) + ".")); | ||
}); | ||
})); | ||
}; | ||
exports.reporter = function (validation) { return (validation.fold(function (errors) { return array.catOptions(errors.map(exports.formatValidationError)); }, function () { return []; })); }; | ||
exports.reporter = function (validation) { return (pipeable_1.pipe(validation, Either_1.fold(function (errors) { return array.compact(errors.map(exports.formatValidationError)); }, function () { return []; }))); }; | ||
//# sourceMappingURL=index.js.map |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5451
32
1
34
+ Addedfp-ts@2.16.9(transitive)
+ Addedio-ts@2.2.22(transitive)
- Removedfp-ts@1.19.5(transitive)
- Removedio-ts@1.10.4(transitive)
Updatedfp-ts@^2.0.2
Updatedio-ts@^2.0.0