More expressive error messsage possible for "Expected string, received string"
See original GitHub issueThanks for zod, I love it!
const { z } = require("zod");
const Special = z.literal("wat");
console.log(Special.safeParse("nah").error.issues[0].message);
which outputs Expected string, received string
Wouldn’t Expected "wat", received "nah"
be more preferable? I suppose there is some nuance and edge cases where this isn’t feasible?
Issue Analytics
- State:
- Created a year ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
stack index 1, expected string, received no value: bad get ...
The error is at the bottom of this post. It doesn't make sense. None of my factories take strings and it should be...
Read more >How can I check if a function throws an error which contains a ...
1 Answer 1 · regular expression: error message matches the pattern · string: error message includes the substring · error object: error message...
Read more >SyntaxError: unterminated string literal - JavaScript | MDN
The JavaScript error "unterminated string literal" occurs when there is an unterminated string literal somewhere. String literals must be enclosed by single ...
Read more >Web3Js: TypeError: hexToBytes: expected string, got object
I am trying to sign a transaction, but I'm receiving this error: hexToBytes: expected string, got object TypeError: hexToBytes: expected ...
Read more >I get a message about data type mismatch - Microsoft Support
This error indicates that Access cannot match an input value to the data type it expects for the value. For example, if you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For me #1052 is not a sufficient fix, I’d like to know the exact value mismatch. I had an idea over in my PR for a fix that would address it for me:
That said, ofc I’d leave it to the maintainers to close this issue if that feels sufficiently adressed / not important / out of scope.
It should be easy, go for it imo : )