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 2.2.0 to 2.2.1

9

CHANGELOG.md

@@ -14,5 +14,10 @@ # Changelog

**Note**: Gaps between patch versions are faulty/broken releases. **Note**: A feature tagged as Experimental is in a
high state of flux, you're at risk of it changing without notice.
**Note**: Gaps between patch versions are faulty/broken releases.
**Note**: A feature tagged as Experimental is in a high state of flux, you're at risk of it changing without notice.
# 2.2.1
- **Experimental**
- collect all errors while decoding, closes #449 (@gcanti)
# 2.2.0

@@ -19,0 +24,0 @@

@@ -36,6 +36,2 @@ /**

*/
export declare function failures<A = never>(message: string, errors: NonEmptyArray<Tree<string>>): Either<NonEmptyArray<Tree<string>>, A>;
/**
* @since 2.2.0
*/
export declare function fromGuard<A>(guard: G.Guard<A>, expected: string): Decoder<A>;

@@ -42,0 +38,0 @@ /**

@@ -31,7 +31,4 @@ import { either, isLeft, isRight, left, mapLeft, right } from 'fp-ts/es6/Either';

}
/**
* @since 2.2.0
*/
export function failures(message, errors) {
return left([tree(message, errors)]);
function isNotEmpty(as) {
return as.length > 0;
}

@@ -153,6 +150,7 @@ /**

var a = {};
var errors = [];
for (var k in properties) {
var e_1 = properties[k].decode(r[k]);
if (isLeft(e_1)) {
return failures("required property " + JSON.stringify(k), e_1.left);
errors.push(tree("required property " + JSON.stringify(k), e_1.left));
}

@@ -163,3 +161,3 @@ else {

}
return success(a);
return isNotEmpty(errors) ? left(errors) : success(a);
}

@@ -182,2 +180,3 @@ }

var a = {};
var errors = [];
for (var k in properties) {

@@ -194,3 +193,3 @@ // don't add missing properties

if (isLeft(e_2)) {
return failures("optional property " + JSON.stringify(k), e_2.left);
errors.push(tree("optional property " + JSON.stringify(k), e_2.left));
}

@@ -203,3 +202,3 @@ else {

}
return success(a);
return isNotEmpty(errors) ? left(errors) : success(a);
}

@@ -222,6 +221,7 @@ }

var a = {};
var errors = [];
for (var k in r) {
var e_3 = codomain.decode(r[k]);
if (isLeft(e_3)) {
return failures("key " + JSON.stringify(k), e_3.left);
errors.push(tree("key " + JSON.stringify(k), e_3.left));
}

@@ -232,3 +232,3 @@ else {

}
return success(a);
return isNotEmpty(errors) ? left(errors) : success(a);
}

@@ -252,6 +252,7 @@ }

var a = new Array(len);
var errors = [];
for (var i = 0; i < len; i++) {
var e_4 = items.decode(us[i]);
if (isLeft(e_4)) {
return failures("item " + i, e_4.left);
errors.push(tree("item " + i, e_4.left));
}

@@ -262,3 +263,3 @@ else {

}
return success(a);
return isNotEmpty(errors) ? left(errors) : success(a);
}

@@ -284,6 +285,7 @@ }

var a = [];
var errors = [];
for (var i = 0; i < components.length; i++) {
var e_5 = components[i].decode(us[i]);
if (isLeft(e_5)) {
return failures("component " + i, e_5.left);
errors.push(tree("component " + i, e_5.left));
}

@@ -294,3 +296,3 @@ else {

}
return success(a);
return isNotEmpty(errors) ? left(errors) : success(a);
}

@@ -364,4 +366,6 @@ };

}
return failures("required property " + JSON.stringify(tag), [
tree("cannot decode " + JSON.stringify(v) + ", should be " + expected)
return left([
tree("required property " + JSON.stringify(tag), [
tree("cannot decode " + JSON.stringify(v) + ", should be " + expected)
])
]);

@@ -368,0 +372,0 @@ }

@@ -36,6 +36,2 @@ /**

*/
export declare function failures<A = never>(message: string, errors: NonEmptyArray<Tree<string>>): Either<NonEmptyArray<Tree<string>>, A>;
/**
* @since 2.2.0
*/
export declare function fromGuard<A>(guard: G.Guard<A>, expected: string): Decoder<A>;

@@ -42,0 +38,0 @@ /**

@@ -36,9 +36,5 @@ "use strict";

exports.failure = failure;
/**
* @since 2.2.0
*/
function failures(message, errors) {
return Either_1.left([tree(message, errors)]);
function isNotEmpty(as) {
return as.length > 0;
}
exports.failures = failures;
/**

@@ -165,6 +161,7 @@ * @since 2.2.0

var a = {};
var errors = [];
for (var k in properties) {
var e_1 = properties[k].decode(r[k]);
if (Either_1.isLeft(e_1)) {
return failures("required property " + JSON.stringify(k), e_1.left);
errors.push(tree("required property " + JSON.stringify(k), e_1.left));
}

@@ -175,3 +172,3 @@ else {

}
return success(a);
return isNotEmpty(errors) ? Either_1.left(errors) : success(a);
}

@@ -195,2 +192,3 @@ }

var a = {};
var errors = [];
for (var k in properties) {

@@ -207,3 +205,3 @@ // don't add missing properties

if (Either_1.isLeft(e_2)) {
return failures("optional property " + JSON.stringify(k), e_2.left);
errors.push(tree("optional property " + JSON.stringify(k), e_2.left));
}

@@ -216,3 +214,3 @@ else {

}
return success(a);
return isNotEmpty(errors) ? Either_1.left(errors) : success(a);
}

@@ -236,6 +234,7 @@ }

var a = {};
var errors = [];
for (var k in r) {
var e_3 = codomain.decode(r[k]);
if (Either_1.isLeft(e_3)) {
return failures("key " + JSON.stringify(k), e_3.left);
errors.push(tree("key " + JSON.stringify(k), e_3.left));
}

@@ -246,3 +245,3 @@ else {

}
return success(a);
return isNotEmpty(errors) ? Either_1.left(errors) : success(a);
}

@@ -267,6 +266,7 @@ }

var a = new Array(len);
var errors = [];
for (var i = 0; i < len; i++) {
var e_4 = items.decode(us[i]);
if (Either_1.isLeft(e_4)) {
return failures("item " + i, e_4.left);
errors.push(tree("item " + i, e_4.left));
}

@@ -277,3 +277,3 @@ else {

}
return success(a);
return isNotEmpty(errors) ? Either_1.left(errors) : success(a);
}

@@ -300,6 +300,7 @@ }

var a = [];
var errors = [];
for (var i = 0; i < components.length; i++) {
var e_5 = components[i].decode(us[i]);
if (Either_1.isLeft(e_5)) {
return failures("component " + i, e_5.left);
errors.push(tree("component " + i, e_5.left));
}

@@ -310,3 +311,3 @@ else {

}
return success(a);
return isNotEmpty(errors) ? Either_1.left(errors) : success(a);
}

@@ -384,4 +385,6 @@ };

}
return failures("required property " + JSON.stringify(tag), [
tree("cannot decode " + JSON.stringify(v) + ", should be " + expected)
return Either_1.left([
tree("required property " + JSON.stringify(tag), [
tree("cannot decode " + JSON.stringify(v) + ", should be " + expected)
])
]);

@@ -388,0 +391,0 @@ }

{
"name": "io-ts",
"version": "2.2.0",
"description": "TypeScript compatible runtime type system for IO validation",
"version": "2.2.1",
"description": "TypeScript runtime type system for IO decoding/encoding",
"files": [

@@ -66,14 +66,14 @@ "lib",

"typescript",
"validation",
"inference",
"types",
"runtime"
"runtime",
"decoder",
"encoder",
"schema"
],
"keywords": [
"typescript",
"validation",
"inference",
"types",
"runtime"
"runtime",
"decoder",
"encoder",
"schema"
]
}

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

- [API Reference](https://gcanti.github.io/io-ts/modules/)
- [API Reference](https://gcanti.github.io/io-ts/docs/modules)

@@ -29,0 +29,0 @@ ## Usage

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