You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 20, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: docs/guides/nodejs/zod.mdx
+2-7Lines changed: 2 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ updated_at: 2025-03-05
12
12
13
13
# A Unified Approach to validation across APIs, Queues & Jobs with Zod
14
14
15
-
On frontend applications validation can help users enter data in the correct format this stops them from providing empty values, invalid emails, or other common input mistakes.
15
+
Validation can help users enter data in the correct format when interacting with front-end applications. This prevents them from providing empty values, invalid emails, or other common input mistakes.
16
16
17
17
Once data leaves the browser we still need to ensure that the data remains valid:
18
18
@@ -23,7 +23,7 @@ Cloud applications don’t just receive requests from web forms. Data comes from
23
23
24
24
Server-side validation is critical—not just for security, but for maintaining data integrity across the system.
25
25
26
-
With Zod, we can define strict validation rules once and enforce them across APIs, events, and background jobs.
26
+
With [Zod](https://zod.dev/), we can define strict validation rules once and enforce them across APIs, events, and background jobs.
27
27
28
28
## Defining a validation schema with Zod
29
29
@@ -39,11 +39,6 @@ const userSchema = z.object({
39
39
})
40
40
```
41
41
42
-
### Breaking it down:
43
-
44
-
-`name` must be a string and at least 2 characters long. If it's too short, an error message is returned.
45
-
-`email` must follow a valid email format, and Zod will automatically enforce this validation.
46
-
-`age` must be a number and at least 18. If the value is below this threshold, an error message is returned.
47
42
48
43
This schema ensures that any user data passed into the application follows these strict rules.
0 commit comments