Files
local-cal/.ruler/03-ZOD-GUIDE.md
Dmytro Stanchiev 206f028fdf init ruler
Signed-off-by: Dmytro Stanchiev <git@dmytros.dev>
2026-04-06 20:48:07 -04:00

20 lines
653 B
Markdown

## Zod Guidelines
### Schema Definition
- Define all schemas in `src/types.ts`
- Use `z.object()` for objects, `z.array()` for arrays
- Mark optional fields with `.optional()`
- Create generic schemas for reusable structures
### Type Inference
- Always infer types from schemas: `export type Foo = z.infer<typeof FooSchema>`
### Validation
- Use `.parse()` to validate API responses
- Only validate successful responses (`retcode === RESPONSE_CODES.SUCCESS`)
- Return unvalidated responses for error cases
### Patterns
- Follow existing schema naming: `FooSchema` for schemas, `Foo` for types
- Use `ZZZResponseSchema(dataSchema)` for API responses