I'm wondering why ValidationError doesn't return an array of strings, where each item is an error?
According to this screenshot I'm expecting an array like [ "Password, must contain at least 8 characters" , "Password, must include tuna" ]
It looks always return 1 item with the errors concat with , . The thing is, I want to display 1 error at the time, not all of them for a better UX. If I do it in a hacky way extracting the items based on , it won't work for error messages where I add a comma. Is there any workaround for this?
#ValidationError - Zod
10 messages · Page 1 of 1 (latest)
Looks like it could be a problem with the Zod adapter maybe? Because ValidationError isn't meant to be an array
What should be then? For example for pasaword field, if there are 3 errors, I'd like to show one at the time
I don't know, because you haven't provided much info about your setup
I'll paste the whole code from the form to see what i'm doing wrong, thanks mate
Looks like the zod adapter is the one that is smooshing them together
If you want more controls on the errors you can pass a transformErrors function to the adapter. With zod might look like this to only get the first:
validatorAdapter: zodValidator({
transformErrors: (errors) => errors.map((error) => error.message)[0]
}),
is joining all the zod errors in 1 single error applying for all the validators adapters? It looks like an opinionated decision for me. I'll have a look at the codebase and see how the adapters really work
Thanks, I'll have a look at tranaformErrors
Yes it's the default behavior