Is the `.inputValidator` on server functions only meant to be used for type validation?
I am trying to use the
.inputValidator with zod to validate my input but when the input is invalid it throw and when I catch this inside of my component code the entire zod array of errors are serialized instead of showing up as an array. Is this the normal behavior and also why is there nothing in the documentation mentioning this if it is?
3 Replies
flat-fuchsia•2w ago
you need a custom error seralizer. its just not documented yet
the default error serializer will just serialize the message.
here is an example on how to set this up:
https://github.com/TanStack/router/blob/main/e2e/react-start/serialization-adapters/src/CustomError.ts#L18
https://github.com/TanStack/router/blob/main/e2e/react-start/serialization-adapters/src/start.tsx#L8
foreign-sapphireOP•2w ago
Ok I will give this a try and respond here with my results. It would be good if this was documented as there are mentions of using zod in the docs and without this it's kinda not that useful.
flat-fuchsia•2w ago
yeah of course this will be documented