From 063a45d891eba267032d1300ac74fbe2d44ab605 Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Tue, 13 Aug 2024 02:21:37 +0800 Subject: [PATCH] fix: include check for contain fn --- packages/core/src/presets.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/core/src/presets.ts b/packages/core/src/presets.ts index d303f81..067a824 100644 --- a/packages/core/src/presets.ts +++ b/packages/core/src/presets.ts @@ -271,11 +271,17 @@ const genericContainFilter = defineGenericFn([ target: string | unknown | unknown[], ) => { if (typeof value === "string" && typeof target === "string") { + // z.ZodString return value.includes(target); } if (Array.isArray(value)) { + // z.ZodArray return value.includes(target); } + if (typeof value === "string" && Array.isArray(target)) { + // z.ZodUnion<[z.ZodLiteral]> + return target.includes(value); + } throw new Error("Invalid input type!"); }, }, @@ -310,6 +316,9 @@ const genericContainFilter = defineGenericFn([ if (Array.isArray(value)) { return !value.includes(target); } + if (typeof value === "string" && Array.isArray(target)) { + return target.includes(value); + } throw new Error("Invalid input type!"); }, },