Skip to content

Commit ad2ee9c

Browse files
authoredSep 23, 2023
2718 Updated Custom Schemas documentation example to use type narrowing (#2778)
1 parent 28c1927 commit ad2ee9c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1879,7 +1879,7 @@ You can create a Zod schema for any TypeScript type by using `z.custom()`. This
18791879

18801880
```ts
18811881
const px = z.custom<`${number}px`>((val) => {
1882-
return /^\d+px$/.test(val as string);
1882+
return typeof val === "string" ? /^\d+px$/.test(val) : false;
18831883
});
18841884

18851885
type px = z.infer<typeof px>; // `${number}px`

0 commit comments

Comments
 (0)
Please sign in to comment.