question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

More expressive error messsage possible for "Expected string, received string"

See original GitHub issue

Thanks for zod, I love it!

Example:

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:closed
  • Created a year ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Gregoorcommented, Mar 30, 2022

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:

Makes sense, thanks for the info, I can see how not having this in is a better security default. That said, for cases where it matters less like mine, I was thinking of turning errorIncludesInputData once and if #851 lands. Would you be open to a PR that builds on that to show literal values if that flag is set?

That said, ofc I’d leave it to the maintainers to close this issue if that feels sufficiently adressed / not important / out of scope.

1reaction
andresgutgoncommented, Mar 25, 2022

It should be easy, go for it imo : )

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found