Colin McDonnell

Results 258 comments of Colin McDonnell

There are docs here on how to properly define recursive types: https://github.com/colinhacks/zod?tab=readme-ov-file#recursive-types I'm afraid this is a little onerous at the moment and does require an explicit type annotation. This...

I understand the desire for something like this and your use case makes sense. For now I recommend using pipe. ```ts z.string().transform(normalizeUrlLikeString).pipe(z.string().url()) ``` Hopefully it's clear why you can't call...

Thanks, I'll start looking into this.

This has landed in Zod 3.23. https://github.com/colinhacks/zod/releases/tag/v3.23.0

Thanks @schicks, this is an excellent idea.

This has landed in Zod 3.23. https://github.com/colinhacks/zod/releases/tag/v3.23.0

In a lot of cases I'm partial to Pascal-casing, since schemas ultimately represent types. This also enables a pattern that I personally love where a schema and it's inferred type...

Thanks for the PR @sgrsngh2003, it's very well done. Unfortunately, a lot of Zod users have written tests that match against the exact error messages produced by Zod. While technically...

I appreciate this, though unfortunately a lot of users' tests are written to match Zod's exact error messages, so this would be considered a breaking change. I could merge this...

As others have said, this is intended to be a discriminated union and it dramatically improves DX due to TypeScript's automatic type narrowing.