ZodErrors
Adds additional data to Zod validation errors.
Import name: Sentry.zodErrorsIntegration
The Zod Errors integration enhances error reporting for applications using Zod schema validation. When Zod validation fails, this integration captures detailed validation errors (ZodError
instances) and attaches them as additional data to Sentry events.
The Zod Errors integration is not enabled by default. You need to add it to your Sentry configuration:
Copied
Sentry.init({
integrations: [Sentry.zodErrorsIntegration()],
});
The zodErrorsIntegration
accepts the following options:
Type: number
Default: 10
Limits the number of Zod errors inlined in each Sentry event.
Type: boolean
Default: false
Save full list of Zod issues as a JSON attachment in Sentry.
When a Zod validation error occurs, you'll see enhanced error information in Sentry like this:
Copied
[
{
"code": "too_small",
"path": ["name"],
"message": "Name is required",
"minimum": 1,
"type": "string",
"inclusive": true,
"received": ""
},
{
"code": "invalid_string",
"path": ["email"],
"message": "Invalid email format",
"validation": "email",
"received": "invalid-email"
}
]
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").