From f9502526396ad93dd1f860ef354a0907944952d4 Mon Sep 17 00:00:00 2001 From: Anna Bocharova Date: Sun, 1 Sep 2024 21:00:11 +0200 Subject: [PATCH] Ensure consistent imports from `zod` (#2015) --- src/errors.ts | 6 +++--- tests/unit/errors.spec.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/errors.ts b/src/errors.ts index 7c5faf8b1..764a48256 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -1,4 +1,4 @@ -import { ZodError } from "zod"; +import { z } from "zod"; import { getMessageFromError } from "./common-helpers"; import { OpenAPIContext } from "./documentation-helpers"; @@ -38,7 +38,7 @@ export class IOSchemaError extends Error { export class OutputValidationError extends IOSchemaError { public override name = "OutputValidationError"; - constructor(public readonly originalError: ZodError) { + constructor(public readonly originalError: z.ZodError) { super(getMessageFromError(originalError)); } } @@ -47,7 +47,7 @@ export class OutputValidationError extends IOSchemaError { export class InputValidationError extends IOSchemaError { public override name = "InputValidationError"; - constructor(public readonly originalError: ZodError) { + constructor(public readonly originalError: z.ZodError) { super(getMessageFromError(originalError)); } } diff --git a/tests/unit/errors.spec.ts b/tests/unit/errors.spec.ts index 3342a52b7..b7e301729 100644 --- a/tests/unit/errors.spec.ts +++ b/tests/unit/errors.spec.ts @@ -1,4 +1,4 @@ -import { ZodError } from "zod"; +import { z } from "zod"; import { DocumentationError, RoutingError } from "../../src"; import { IOSchemaError, @@ -52,7 +52,7 @@ describe("Errors", () => { }); describe("OutputValidationError", () => { - const zodError = new ZodError([]); + const zodError = new z.ZodError([]); test("should be an instance of IOSchemaError and Error", () => { expect(new OutputValidationError(zodError)).toBeInstanceOf(IOSchemaError); @@ -73,7 +73,7 @@ describe("Errors", () => { }); describe("InputValidationError", () => { - const zodError = new ZodError([]); + const zodError = new z.ZodError([]); test("should be an instance of IOSchemaError and Error", () => { expect(new InputValidationError(zodError)).toBeInstanceOf(IOSchemaError);