When performing validation is it possible to preserve the errors array? #860
-
|
When using Is it possible to preserve the original error array? For instance, given the following schema; The output of However, if using ZodAdapter, the output would be; Link to a reproducible example. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
I don't think so, because a validation can only return a e.g., just show one of the error messages. validatorAdapter: zodValidator({
transformErrors: (e) => {
return e?.[0]?.message
},
}), |
Beta Was this translation helpful? Give feedback.
I don't think so, because a validation can only return a
ValidationErrorwhich is astring. However, you can access the issues array and transform the error message to your liking using thetransformErrorsfunction that is passed to the adapter.e.g., just show one of the error messages.