Skip to content

Commit

Permalink
refactor: make zod non requried dep
Browse files Browse the repository at this point in the history
  • Loading branch information
Bekacru committed Oct 23, 2024
1 parent a4effe4 commit 342f253
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/better-fetch/src/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodSchema, type z } from "zod";
import type { ZodSchema, z } from "zod";
import { BetterFetchError } from "./error";
import { initializePlugins } from "./plugins";
import { createRetryStrategy } from "./retry";
Expand Down Expand Up @@ -127,8 +127,10 @@ export const betterFetch = async <
* Parse the data if the output schema is defined
*/
if (context?.output) {
if (context.output instanceof ZodSchema && !context.disableValidation) {
successContext.data = context.output.parse(successContext.data);
if (context.output && !context.disableValidation) {
successContext.data = (context.output as ZodSchema).parse(
successContext.data,
);
}
}

Expand Down

0 comments on commit 342f253

Please sign in to comment.