Skip to content

Zod Schemas

Stelo CMS uses Zod for runtime type validation and schema definition across the application.

export const localizedStringSchema = z.record(
z.enum(['en', 'fr', 'es']),
z.string().min(1)
);
export const localizedRichContentSchema = z.record(
z.enum(['en', 'fr', 'es']),
z.object({
body: z.string(),
excerpt: z.string().optional(),
featuredImage: z.string().url().optional()
})
);
export const createPageSchema = z.object({
title: localizedStringSchema,
content: localizedRichContentSchema,
slug: localizedStringSchema,
metadata: z.record(z.any()).optional(),
published: z.boolean().default(false)
});
  • Runtime type safety
  • Clear error messages
  • Automatic TypeScript inference
  • Input sanitization

This section will be expanded with detailed schema definitions.