New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

funtypes

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

funtypes - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

14

.size-snapshot.json
{
"index.js": {
"bundled": 25249,
"minified": 16327,
"gzipped": 5099
"bundled": 25255,
"minified": 16329,
"gzipped": 5100
},
"index.mjs": {
"bundled": 24842,
"minified": 16199,
"gzipped": 5064,
"bundled": 24848,
"minified": 16201,
"gzipped": 5065,
"treeshaked": {

@@ -17,3 +17,3 @@ "rollup": {

"webpack": {
"code": 9732
"code": 9734
}

@@ -20,0 +20,0 @@ }

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

l = i.success && r ? r(i.value) : i;
if (!l.success) return l;
if (!l.success) return (s = l);
if (a) {

@@ -110,0 +110,0 @@ const e = ((e, t) =>

{
"name": "funtypes",
"version": "3.0.1",
"version": "3.0.2",
"description": "Runtime validation for static types",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -353,3 +353,3 @@ import { Result, Union, Intersect, Constraint, ConstraintCheck, Brand, Failure } from './index';

const result = sourceResult.success && fn ? fn(sourceResult.value) : sourceResult;
if (!result.success) return result;
if (!result.success) return (cache = result);
if (hasCycle) {

@@ -356,0 +356,0 @@ const unwrapResult = attemptMixin(cache.value, result.value);

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

import { Union, String, Literal, Object, Number, InstanceOf, Tuple } from '..';
import { Array, Union, String, Literal, Object, Number, InstanceOf, Tuple } from '..';

@@ -584,2 +584,137 @@ const ThreeOrString = Union(Literal(3), String);

});
it('does not break when reusing the same validator in multiple parts of the union', () => {
const InnerObject = Object({
myProp: String,
});
const OuterObjectA = Object({
key: Object({ value: String }),
body: InnerObject,
});
const OuterObjectB = Object({
key: Object({ value: Number }),
body: InnerObject,
});
expect(
Union(OuterObjectA, OuterObjectB).safeParse({
key: { value: 42 },
body: { noMyPropHere: true },
}),
).toMatchInlineSnapshot(`
Object {
"fullError": Array [
"Unable to assign {key: {value: 42}, body: {noMyPropHere: true}} to { key: { value: string; }; body: { myProp: string; }; } | { key: { value: number; }; body: { myProp: string; }; }",
Array [
"Unable to assign {key: {value: 42}, body: {noMyPropHere: true}} to { key: { value: string; }; body: { myProp: string; }; }",
Array [
"The types of \\"key\\" are not compatible",
Array [
"Unable to assign {value: 42} to { value: string; }",
Array [
"The types of \\"value\\" are not compatible",
Array [
"Expected string, but was 42",
],
],
],
],
Array [
"The types of \\"body\\" are not compatible",
Array [
"Unable to assign {noMyPropHere: true} to { myProp: string; }",
Array [
"The types of \\"myProp\\" are not compatible",
Array [
"Expected string, but was undefined",
],
],
],
],
],
Array [
"And unable to assign {key: {value: 42}, body: {noMyPropHere: true}} to { key: { value: number; }; body: { myProp: string; }; }",
Array [
"The types of \\"body\\" are not compatible",
Array [
"Unable to assign {noMyPropHere: true} to { myProp: string; }",
Array [
"The types of \\"myProp\\" are not compatible",
Array [
"Expected string, but was undefined",
],
],
],
],
],
],
"message": "Expected { key: { value: string; }; body: { myProp: string; }; } | { key: { value: number; }; body: { myProp: string; }; }, but was {key: {value: 42}, body: {noMyPropHere: true}}",
"success": false,
}
`);
const InnerArray = Array(String);
const OuterObjectWithArrayA = Object({
key: Object({ value: String }),
body: InnerArray,
});
const OuterObjectWithArrayB = Object({
key: Object({ value: Number }),
body: InnerArray,
});
expect(
Union(OuterObjectWithArrayA, OuterObjectWithArrayB).safeParse({
key: { value: 42 },
body: [42],
}),
).toMatchInlineSnapshot(`
Object {
"fullError": Array [
"Unable to assign {key: {value: 42}, body: [42]} to { key: { value: string; }; body: string[]; } | { key: { value: number; }; body: string[]; }",
Array [
"Unable to assign {key: {value: 42}, body: [42]} to { key: { value: string; }; body: string[]; }",
Array [
"The types of \\"key\\" are not compatible",
Array [
"Unable to assign {value: 42} to { value: string; }",
Array [
"The types of \\"value\\" are not compatible",
Array [
"Expected string, but was 42",
],
],
],
],
Array [
"The types of \\"body\\" are not compatible",
Array [
"Unable to assign [42] to string[]",
Array [
"The types of [0] are not compatible",
Array [
"Expected string, but was 42",
],
],
],
],
],
Array [
"And unable to assign {key: {value: 42}, body: [42]} to { key: { value: number; }; body: string[]; }",
Array [
"The types of \\"body\\" are not compatible",
Array [
"Unable to assign [42] to string[]",
Array [
"The types of [0] are not compatible",
Array [
"Expected string, but was 42",
],
],
],
],
],
],
"message": "Expected { key: { value: string; }; body: string[]; } | { key: { value: number; }; body: string[]; }, but was {key: {value: 42}, body: [42]}",
"success": false,
}
`);
});
});

Sorry, the diff of this file is not supported yet

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