Colin McDonnell

Results 258 comments of Colin McDonnell

I agree, this is a very useful pattern :) https://github.com/colinhacks/zod#nonempty

Definitely an interesting solution. I believe all of this can already by accomplished with `ctx.addIssue` inside a transform, right? Admittedly that API is a bit odd, since you still need...

> Yes, the default error map has the highest priority, no matter what you do... If there's a scenario where the default map takes precedence over one passed into `.parse`...

We're using the built-in `URL` constructor to validate URLs. It's the closest thing to a standard available in JS. Anyone with other requirements can use their own regex easily.

Good idea! I definitely want to support this eventually. For now, you'll have to implement this with `z.custom`: ```ts const literal = z.custom((val) => /^\d+\.\d+\.\d+$/g.test(val as string) ); ```

I'll look into this in the near future. This decision is intertwined with the idea of some sort of "pipeline" feature: ``` z.string().transform(val => val.length).pipe(z.number()).min(5); ``` So hold off on...

Branded types were added in the latest release: https://github.com/colinhacks/zod/pull/1279

This is a well made PR, but I'm not convinced it's worth introducing a new subclass of `ZodType` just to add the `class` getter. Is there a compelling argument in...

This is a good PR but I'm generally opposed to contextual validations. Zod schemas should be self-contained, and schema that rely on params break encapsulation. https://github.com/colinhacks/zod/issues/487#issuecomment-860231900

I like this idea unironically.