segfault - Hey! I'm currently testing my schema...
Hey! I'm currently testing my schemas and have encountered what I believe to be a typescript type definition issue. I am examining error cases where parsing a string with a regex results in an error. My goal is to verify that the failure validation was due to the regex and not some other reason. However, when accessing the
error.issues
field, which has the ZodIssue
type, it does not recognize the validation
field. I can see that it is present when I use a simple console.log
. Is there a workaround to access validation
with type checking activated?
Here is an example of the schema. It works fine in JavaScript or when TypeScript type checking is disabled.
Solution:Jump to solution
Okay, I found the specific type definition for my case. The link to the error variants in the documentation page is broken (https://zod.dev/ERROR_HANDLING?id=zodissue), so it was a bit tricky.
GitHub
TypeScript-first schema validation with static type inference
TypeScript-first schema validation with static type inference
1 Reply
Solution
Okay, I found the specific type definition for my case. The link to the error variants in the documentation page is broken (https://zod.dev/ERROR_HANDLING?id=zodissue), so it was a bit tricky.
GitHub
TypeScript-first schema validation with static type inference
TypeScript-first schema validation with static type inference