ReturnsValidationError: Value does not match validator. Use validator like zod to validate value
Hi, is it possible to check what exactly is different and unexpected from when getting a ReturnsValidationError? Currently my value and validator are huge and the error message doesn't specify what it expects and it's very difficult for me to find out what the discrepency is.
4 Replies
Here is the full error message, it's pretty massive because of my validator so I can't feasibly read it. I'd greatly appreciate if it was possible to find out what the validation error is specifically like how zod does.
This would be tough to do, especially with unions. Would have to show expected/actual for every member of the union compared to your input somehow.
And yeah that's a massive validator. AI is your best bet for parsing out errors. This also probably points to some kind of type issue, are you asserting types anywhere?
if you store the value somewhere you could cut up the object and run the
validate
helper on each sub-union? Agreed the error messages here could use some loveYeah I've found that types can be weirdly inconsistent. Such as when a mutation or query has a returns type but typescript only sees it as any, or it not being clear on implicit DB types like _createdAt and _id.
For this issue specifically I just gave up on having the validator in the function, but typescript still accepted with the exact same type. Things like this have been happening to me more and more often so I need to either just the convex validtor (still keep types) and check these things further down the line.