Replies: 1 comment
-
|
You can't access the original (untransformed) value inside the error function of If you need to distinguish between cases like an empty string and zero, the recommended workaround is to avoid const schema = z.object({
price: z
.string()
.transform(Number)
.pipe(z.number().min(1).max(10000))
})This pattern lets you inspect the original string before it's converted, so you can customize errors as needed (discussion). Let me know if this solves your problem—if so, feel free to close the issue! To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
i want to get the original value in z.coerce
Beta Was this translation helpful? Give feedback.
All reactions