@ts-rest/core
Advanced tools
Comparing version 3.21.0 to 3.21.1
16
index.js
@@ -9,7 +9,9 @@ 'use strict'; | ||
const isZodObject = (obj) => { | ||
const isZodEffects = typeof (obj === null || obj === void 0 ? void 0 : obj.innerType) === 'function'; | ||
const maybeZodObject = isZodEffects | ||
? obj === null || obj === void 0 ? void 0 : obj.innerType() | ||
: obj; | ||
return typeof (maybeZodObject === null || maybeZodObject === void 0 ? void 0 : maybeZodObject.passthrough) === 'function'; | ||
if (typeof (obj === null || obj === void 0 ? void 0 : obj.passthrough) === 'function') { | ||
return true; | ||
} | ||
if (typeof (obj === null || obj === void 0 ? void 0 : obj.innerType) === 'function') { | ||
return isZodObject(obj === null || obj === void 0 ? void 0 : obj.innerType()); | ||
} | ||
return false; | ||
}; | ||
@@ -24,3 +26,3 @@ const isZodObjectStrict = (obj) => { | ||
if ('innerType' in obj) { | ||
return obj.innerType().shape; | ||
return extractZodObjectShape(obj.innerType()); | ||
} | ||
@@ -42,3 +44,3 @@ return obj.shape; | ||
const checkZodSchema = (data, schema, { passThroughExtraKeys = false } = {}) => { | ||
if (isZodObject(schema)) { | ||
if (isZodType(schema)) { | ||
const result = schema.safeParse(data); | ||
@@ -45,0 +47,0 @@ if (result.success) { |
{ | ||
"name": "@ts-rest/core", | ||
"version": "3.21.0", | ||
"version": "3.21.1", | ||
"description": "RPC-like experience over a regular REST API, with type safe server implementations 🪄", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -9,7 +9,3 @@ import { z } from 'zod'; | ||
export declare const isZodObjectStrict: (obj: unknown) => obj is z.AnyZodObject; | ||
export declare const extractZodObjectShape: <T extends z.AnyZodObject | z.ZodEffects<z.AnyZodObject, { | ||
[x: string]: any; | ||
}, { | ||
[x: string]: any; | ||
}>>(obj: T) => any; | ||
export declare const extractZodObjectShape: <T extends z.AnyZodObject | z.ZodEffects<z.ZodTypeAny, any, any>>(obj: T) => any; | ||
export declare const zodMerge: (objectA: unknown, objectB: unknown) => {}; | ||
@@ -16,0 +12,0 @@ export declare const checkZodSchema: (data: unknown, schema: unknown, { passThroughExtraKeys }?: { |
Sorry, the diff of this file is not supported yet
51065