From ad2ee9ccf723c4388158ff6b8669c2a6cdc85643 Mon Sep 17 00:00:00 2001 From: mitchgollub <37623776+mitchgollub@users.noreply.github.com> Date: Sat, 23 Sep 2023 14:55:02 -0400 Subject: [PATCH] 2718 Updated Custom Schemas documentation example to use type narrowing (#2778) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 78cf45e7b..e693bd099 100644 --- a/README.md +++ b/README.md @@ -1879,7 +1879,7 @@ You can create a Zod schema for any TypeScript type by using `z.custom()`. This ```ts const px = z.custom<`${number}px`>((val) => { - return /^\d+px$/.test(val as string); + return typeof val === "string" ? /^\d+px$/.test(val) : false; }); type px = z.infer; // `${number}px`