Files
plex-playlist/frontend/src/validation.ts

31 lines
818 B
TypeScript
Raw Normal View History

/**
* Zod validation setup with automatic test hooks
* Schemas are automatically validated during test runs via test-setup.ts
*/
import { z } from 'zod';
// Global schemas for automatic validation
export const PlaylistSchema = z.object({
id: z.string().uuid(),
name: z.string().min(1),
description: z.string().optional(),
tracks: z.array(z.string()).default([]),
});
export const UserSchema = z.object({
id: z.number(),
username: z.string().min(1),
email: z.string().email(),
preferences: z
.object({
theme: z.enum(['light', 'dark']).default('light'),
notifications: z.boolean().default(true),
})
.default({}),
});
// Inferred types (no manual type definitions needed)
export type Playlist = z.infer<typeof PlaylistSchema>;
export type User = z.infer<typeof UserSchema>;