Skip to content

Commit d26afb1

Browse files
authored
docs(JS): Add docs for ZodErrors (#14630)
## DESCRIBE YOUR PR Documents getsentry/sentry-javascript#11144 closes #14626 ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs)
1 parent 4181ac6 commit d26afb1

16 files changed

+79
-1
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: ZodErrors
3+
description: "Adds additional data to Zod validation errors."
4+
---
5+
6+
_Import name: `Sentry.zodErrorsIntegration`_
7+
8+
The Zod Errors integration enhances error reporting for applications using [Zod](https://zod.dev/) schema validation.
9+
When Zod validation fails, this integration captures detailed validation errors (`ZodError` instances) and attaches them
10+
as additional data to Sentry events.
11+
12+
The Zod Errors integration is not enabled by default. You need to add it to your Sentry configuration:
13+
14+
```javascript
15+
Sentry.init({
16+
integrations: [
17+
Sentry.zodErrorsIntegration(),
18+
],
19+
});
20+
```
21+
22+
## Options
23+
24+
The `zodErrorsIntegration` accepts the following options:
25+
26+
### `limit`
27+
28+
_Type: `number`_
29+
_Default: `10`_
30+
31+
Limits the number of Zod errors inlined in each Sentry event.
32+
33+
### `saveZodIssuesAsAttachment`
34+
35+
_Type: `boolean`_
36+
_Default: `false`_
37+
38+
Save full list of Zod issues as a JSON attachment in Sentry.
39+
40+
## Example Additional Error Data
41+
42+
When a Zod validation error occurs, you'll see enhanced error information in Sentry like this:
43+
44+
```json
45+
[
46+
{
47+
"code": "too_small",
48+
"path": ["name"],
49+
"message": "Name is required",
50+
"minimum": 1,
51+
"type": "string",
52+
"inclusive": true,
53+
"received": ""
54+
},
55+
{
56+
"code": "invalid_string",
57+
"path": ["email"],
58+
"message": "Invalid email format",
59+
"validation": "email",
60+
"received": "invalid-email"
61+
}
62+
]
63+
```

platform-includes/configuration/integrations/javascript.astro.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,4 @@ Depending on whether an integration enhances the functionality of a particular r
8282
| [`nodeProfilingIntegration`](./nodeprofiling) | | || |
8383
| [`trpcMiddleware`](./trpc) | ||||
8484
| [`openAIIntegration`](./openai) || || |
85+
| [`zodErrorsIntegration`](./zodErrors) | | | ||

platform-includes/configuration/integrations/javascript.aws-lambda.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@
4444
| [`rewriteFramesIntegration`](./rewriteframes) | || | |
4545
| [`tediousIntegration`](./tedious) | | || |
4646
| [`trpcMiddleware`](./trpc) | ||||
47+
| [`zodErrorsIntegration`](./zodErrors) | | | ||

platform-includes/configuration/integrations/javascript.bun.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@
3838
| [`rewriteFramesIntegration`](./rewriteframes) | || | |
3939
| [`supabaseIntegration`](./supabase) | ||| | |
4040
| [`trpcMiddleware`](./trpc) | ||||
41+
| [`zodErrorsIntegration`](./zodErrors) | | | ||

platform-includes/configuration/integrations/javascript.connect.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@
4343
| [`nodeProfilingIntegration`](./nodeprofiling) | | || |
4444
| [`prismaIntegration`](./prisma) | | || |
4545
| [`trpcMiddleware`](./trpc) | ||||
46+
| [`zodErrorsIntegration`](./zodErrors) | | | ||

platform-includes/configuration/integrations/javascript.deno.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
| [`rewriteFramesIntegration`](./rewriteframes) | || | | |
1717
| [`supabaseIntegration`](./supabase) | ||| | |
1818
| [`trpcMiddleware`](./trpc) | ||| ||
19+
| [`zodErrorsIntegration`](./zodErrors) | | | ||

platform-includes/configuration/integrations/javascript.fastify.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@
4242
| [`localVariablesIntegration`](./localvariables) | || | |
4343
| [`nodeProfilingIntegration`](./nodeprofiling) | | || |
4444
| [`rewriteFramesIntegration`](./rewriteframes) | || | |
45-
| [`supabaseIntegration`](./supabase) | ||| | |
45+
| [`supabaseIntegration`](./supabase) | ||| |
4646
| [`trpcMiddleware`](./trpc) | ||||
47+
| [`zodErrorsIntegration`](./zodErrors) | | | ||

platform-includes/configuration/integrations/javascript.gcp-functions.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@
4444
| [`rewriteFramesIntegration`](./rewriteframes) | || | |
4545
| [`tediousIntegration`](./tedious) | | || |
4646
| [`trpcMiddleware`](./trpc) | ||||
47+
| [`zodErrorsIntegration`](./zodErrors) | | | ||

platform-includes/configuration/integrations/javascript.hapi.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@
4444
| [`rewriteFramesIntegration`](./rewriteframes) | || | |
4545
| [`supabaseIntegration`](./supabase) | ||| | |
4646
| [`trpcMiddleware`](./trpc) | ||||
47+
| [`zodErrorsIntegration`](./zodErrors) | | | ||

platform-includes/configuration/integrations/javascript.nestjs.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@
4545
| [`trpcMiddleware`](./trpc) | ||||
4646
| [`unleashIntegration`](./unleash) | | | ||
4747
| [`openAIIntegration`](./openai) || || |
48+
| [`zodErrorsIntegration`](./zodErrors) | | | ||

0 commit comments

Comments
 (0)