.gemini/skills/zod-validation/SKILL.md
Input validation patterns with Zod in LivestockAI server functions
npx skillsauth add captjay98/gemini-livestockai Zod ValidationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
LivestockAI uses Zod for runtime input validation in server functions.
ALWAYS use Zod validators, not identity functions:
import { createServerFn } from '@tanstack/react-start'
import { z } from 'zod'
// ✅ Correct - Zod validation
export const createBatchFn = createServerFn({ method: 'POST' })
.inputValidator(
z.object({
farmId: z.string().uuid(),
species: z.string().min(1).max(100),
quantity: z.number().int().positive(),
}),
)
.handler(async ({ data }) => {
// data is fully typed and validated
})
// ❌ Wrong - No validation
.inputValidator((data: { farmId: string }) => data)
farmId: z.string().uuid()
farmId: z.string().uuid().optional()
status: z.enum(['active', 'depleted', 'sold'])
livestockType: z.enum(['poultry', 'fish', 'cattle', 'goats', 'sheep', 'bees'])
page: z.number().int().positive()
quantity: z.number().int().positive()
amount: z.number().nonnegative()
percentage: z.number().min(0).max(100)
date: z.coerce.date()
targetDate: z.coerce.date().optional()
name: z.string().min(1).max(100)
email: z.string().email()
notes: z.string().max(500).nullish()
// Optional (can be undefined)
notes: z.string().optional()
// Nullable (can be null)
notes: z.string().nullable()
// Both (can be undefined or null)
notes: z.string().nullish()
const createBatchSchema = z.object({
farmId: z.string().uuid(),
livestockType: z.enum([
'poultry',
'fish',
'cattle',
'goats',
'sheep',
'bees',
]),
species: z.string().min(1).max(100),
breedId: z.string().uuid().nullish(),
initialQuantity: z.number().int().positive(),
acquisitionDate: z.coerce.date(),
costPerUnit: z.number().nonnegative(),
batchName: z.string().max(100).nullish(),
targetHarvestDate: z.coerce.date().nullish(),
notes: z.string().max(500).nullish(),
})
const paginatedQuerySchema = z.object({
page: z.number().int().positive().optional().default(1),
pageSize: z.number().int().positive().max(100).optional().default(10),
sortBy: z.string().optional(),
sortOrder: z.enum(['asc', 'desc']).optional(),
search: z.string().optional(),
})
tanstack-start - Server function patternserror-handling - Validation error handlingdata-ai
Input validation patterns with Zod in LivestockAI server functions
testing
Unit testing patterns with Vitest in LivestockAI
tools
Server → Service → Repository pattern for feature organization
data-ai
Server-side rendering and server functions with TanStack Start in LivestockAI