Daniel Breiner
Daniel Breiner
It is possible, but you need to implement the `min` yourself using `superRefine`. https://github.com/colinhacks/zod#abort-early ```js const schemaA = z.object({ name: z .string() .min(3) .refine(async (val) => { if (true /*...
Any update on when we may see this merged? Or the underlying issue addressed in a different way?
Since `refine` currently does output type narrowing, but `superRefine` does not (#1602), this may be extra desirable in cases like #1598 where not aborting early may lead to unexpected exceptions.
Interestingly, the `refinement` method (not mentioned in docs) takes an `IssueData` parameter just like `RefinementCtx.addIssue` in `superRefine`, which allows the refinement to abort early using `fatal`. ```js const baseSchema =...
@maxArturo Looks great, thanks a lot for the PR.
Yes, `refine` infers the narrowed type, but `superRefine` has no way of doing so. ```js refine( check: (arg: Output) => arg is RefinedOutput, message?: /* ... */ ): ZodEffects; superRefine:...
It seems to me adding an option to abort on `refine` failure is the way to go in this case, but the docs should mention the possible runtime/static type mismatch...
Alright, I did some cleaning up and split this issue into three: #1602 - Add a way for .superRefine() to narrow down the output type #1603 - Add an option...
Thank you for the clarification, makes a lot of sense. What you propose is reasonable and would certainly fix all the problems I opened this issue for. I will rename...
That button is used for selecting the current project (enabled only if you have multiple ones). Though I don't think it would be a bad idea to add a new...