Comparing version 2.0.0-beta.22 to 2.0.0-beta.23
@@ -284,2 +284,24 @@ "use strict"; | ||
}); }); | ||
test('test nonexistent keys', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var Schema, obj, result; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
Schema = z.union([ | ||
z.object({ | ||
a: z.string(), | ||
}), | ||
z.object({ | ||
b: z.number(), | ||
}), | ||
]); | ||
obj = { a: 'A' }; | ||
return [4, Schema.spa(obj)]; | ||
case 1: | ||
result = _a.sent(); | ||
expect(result.success).toBe(true); | ||
return [2, result]; | ||
} | ||
}); | ||
}); }); | ||
//# sourceMappingURL=object.test.js.map |
@@ -424,4 +424,5 @@ "use strict"; | ||
: undefined; | ||
if (!keyValidator) | ||
if (!keyValidator) { | ||
return "continue"; | ||
} | ||
if (!Object.keys(data).includes(key)) { | ||
@@ -431,6 +432,18 @@ try { | ||
if (output === undefined) { | ||
return "continue"; | ||
} | ||
else { | ||
objectPromises[key] = PseudoPromise_1.PseudoPromise.resolve(output); | ||
} | ||
} | ||
catch (err) { } | ||
catch (err) { | ||
if (err instanceof ZodError_1.ZodError) { | ||
var zerr = err; | ||
ERROR.addIssues(zerr.issues); | ||
objectPromises[key] = PseudoPromise_1.PseudoPromise.resolve(util_1.INVALID); | ||
} | ||
else { | ||
throw err; | ||
} | ||
} | ||
return "continue"; | ||
} | ||
@@ -548,3 +561,4 @@ objectPromises[key] = new PseudoPromise_1.PseudoPromise().then(function () { | ||
try { | ||
var unionValueProm = PseudoPromise_1.PseudoPromise.resolve(opt.parse(data, params)); | ||
var parseProm = opt.parse(data, params); | ||
var unionValueProm = PseudoPromise_1.PseudoPromise.resolve(parseProm); | ||
isValid_1 = true; | ||
@@ -551,0 +565,0 @@ return unionValueProm; |
@@ -81,3 +81,14 @@ "use strict"; | ||
try { | ||
return Promise.all(pps.map(function (pp) { return pp.getValueAsync(); })); | ||
var allValues = Promise.all(pps.map(function (pp) { | ||
try { | ||
var asdf = pp.getValueAsync(); | ||
return asdf; | ||
} | ||
catch (err) { | ||
return util_1.INVALID; | ||
} | ||
})).then(function (vals) { | ||
return vals; | ||
}); | ||
return allValues; | ||
} | ||
@@ -84,0 +95,0 @@ catch (err) { } |
{ | ||
"name": "zod", | ||
"version": "2.0.0-beta.22", | ||
"version": "2.0.0-beta.23", | ||
"description": "TypeScript-first schema declaration and validation library with static type inference", | ||
@@ -5,0 +5,0 @@ "main": "./lib/cjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
679448
9899