import { z } from 'zod';
// Simple object
const SimpleSchema = z.object({
title: z.string(),
count: z.number()
});
// Nested objects
const NestedSchema = z.object({
user: z.object({
name: z.string(),
profile: z.object({
bio: z.string(),
links: z.array(z.string())
})
})
});
// Arrays
const ListSchema = z.object({
items: z.array(z.object({
id: z.number(),
name: z.string(),
active: z.boolean()
}))
});
// Enums
const StatusSchema = z.object({
status: z.enum(['pending', 'active', 'completed']),
priority: z.enum(['low', 'medium', 'high'])
});
// Optional fields
const OptionalSchema = z.object({
required: z.string(),
optional: z.string().optional(),
withDefault: z.string().default('default value')
});