Skip to content

Commit

Permalink
2718 Updated Custom Schemas documentation example to use type narrowi…
Browse files Browse the repository at this point in the history
…ng (#2778)
  • Loading branch information
mitchgollub authored Sep 23, 2023
1 parent 28c1927 commit ad2ee9c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof px>; // `${number}px`
Expand Down

0 comments on commit ad2ee9c

Please sign in to comment.