Comparing version 0.0.33 to 0.0.34
@@ -5,5 +5,5 @@ export declare abstract class Type<T> { | ||
abstract and<K extends AnyType>(schema: K): any; | ||
or<K extends AnyType>(schema: K): UnionType<[Type<T>, K]>; | ||
optional(): OptionalType<Type<T>>; | ||
nullable(): NullableType<Type<T>>; | ||
or<K extends AnyType>(schema: K): UnionType<[this, K]>; | ||
optional(): OptionalType<this>; | ||
nullable(): NullableType<this>; | ||
} | ||
@@ -10,0 +10,0 @@ export declare class ValidationError extends Error { |
@@ -303,2 +303,23 @@ "use strict"; | ||
} | ||
if (keys.length === 0 && keySig) { | ||
const convVal = this[coercionTypeSybol] ? {} : undefined; | ||
for (const key in value) { | ||
try { | ||
if (convVal) { | ||
convVal[key] = keySig.parse(value[key], { suppressPathErrMsg: true }); | ||
} | ||
else { | ||
keySig.parse(value[key], { suppressPathErrMsg: true }); | ||
} | ||
} | ||
catch (err) { | ||
const path = err.path ? [key, ...err.path] : [key]; | ||
const msg = parseOpts.suppressPathErrMsg | ||
? err.message | ||
: `error parsing object at path: "${prettyPrintPath(path)}" - ${err.message}`; | ||
throw new ValidationError(msg, path); | ||
} | ||
} | ||
return convVal || value; | ||
} | ||
if (keySig) { | ||
@@ -305,0 +326,0 @@ const convVal = this[coercionTypeSybol] ? {} : undefined; |
{ | ||
"name": "myzod", | ||
"version": "0.0.33", | ||
"version": "0.0.34", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./libs/index.js", |
62655
1109