## MODIFIED Requirements ### Requirement: Define Valibot validators derived from Drizzle tables The package SHALL export Valibot schemas derived from Drizzle table definitions using `createInsertSchema` and `createUpdateSchema` from `drizzle-orm/valibot`, replacing the previous hand-written Superstruct schemas. #### Scenario: Insert schema available for each table - **WHEN** a table is defined in Drizzle - **THEN** a `createInsertSchema` SHALL be exported for that table, with auto-generated defaults, nullability, and column type validation #### Scenario: Update schema available for each table - **WHEN** a table is defined in Drizzle - **THEN** a `createUpdateSchema` SHALL be exported for that table, with all non-generated fields marked optional #### Scenario: Enum fields validated via picklist - **WHEN** a `text()` column has a CHECK constraint restricting allowed values - **THEN** the corresponding Valibot schema SHALL use `picklist()` refinement derived from the matching constant array in `drizzle/enums.ts` #### Scenario: Validator validates correct data - **WHEN** data matching the schema is passed to `v.parse()` - **THEN** the validator SHALL return the validated data without throwing #### Scenario: Validator rejects invalid data - **WHEN** data not matching the schema is passed to `v.parse()` - **THEN** the validator SHALL throw a `ValiError` with details about the validation failure ## REMOVED Requirements ### Requirement: Define Superstruct validators for data shapes **Reason**: Replaced by Valibot schemas auto-derived from Drizzle tables via `drizzle-orm/valibot` **Migration**: Replace `import { ProjectCreate } from "@workspace/schema"` with `import { projectInsert } from "@workspace/schema"` or use the Valibot equivalent ### Requirement: Validator composability **Reason**: Redundant — Valibot schemas derived from Drizzle already handle nested types through table relations **Migration**: No migration needed; Valibot schemas are flat by design (one schema per table) ### Requirement: Optional and default fields **Reason**: Handled natively by `createInsertSchema` (omits generated columns) and `createUpdateSchema` (makes all fields optional). Superstruct's `optional()` and `defaulted()` combinators no longer needed. **Migration**: Use `createUpdateSchema` for partial-update shapes instead of manually wrapping with `optional()`