Performance: Schema definition
MEDIUM IMPACT
Schema definition affects the initial data validation and serialization speed, impacting server response time and client hydration speed.
import { z } from 'zod'; const schema = z.object({ name: z.string(), age: z.number().min(0), email: z.string().email(), address: z.object({ street: z.string(), city: z.string(), zip: z.string() }) });
import * as yup from 'yup'; const schema = yup.object().shape({ name: yup.string().required(), age: yup.number().required().min(0), email: yup.string().email().required(), address: yup.object().shape({ street: yup.string().required(), city: yup.string().required(), zip: yup.string().required() }) });
| Pattern | Server Validation Time | Bundle Size Impact | Client Hydration Impact | Verdict |
|---|---|---|---|---|
| Yup schema | 20-50ms | +15kb | Slower hydration | [X] Bad |
| Zod schema | 10-25ms | +5kb | Faster hydration | [OK] Good |