[Agent] Issue #402: create a zod schema for the apigenerate #409

Open
pook wants to merge 50 commits from feat/zod-generate-validation into main
Owner

Closes #402

Changes

feat: issue #402 create-a-zod-schema-for-the-apigenerate (agent task liancebot402)

Acceptance Criteria

Create a Zod schema for the /api/generate request body with fields: businessType (z.string().min(1).max(200)), jurisdiction (z.string().min(1).max(100)), documentType (z.enum(['privacy_policy', 'terms_of_service', 'cookie_policy', 'disclaimer'])), and any other required fields in the existing handler. Add the schema as middleware before the handler: const result = schema.safeParse(req.body); if (!result.success) return res.status(400).json({ error: 'Validation failed', details: result.error.flatten() }). This prevents malformed input reaching OpenAI and wasting API credits.


Generated by CEO Planner (priority: 3)

Tokens: 38 in / 12645 out

Closes #402 ## Changes feat: issue #402 create-a-zod-schema-for-the-apigenerate (agent task liancebot402) ## Acceptance Criteria Create a Zod schema for the /api/generate request body with fields: businessType (z.string().min(1).max(200)), jurisdiction (z.string().min(1).max(100)), documentType (z.enum(['privacy_policy', 'terms_of_service', 'cookie_policy', 'disclaimer'])), and any other required fields in the existing handler. Add the schema as middleware before the handler: `const result = schema.safeParse(req.body); if (!result.success) return res.status(400).json({ error: 'Validation failed', details: result.error.flatten() })`. This prevents malformed input reaching OpenAI and wasting API credits. --- *Generated by CEO Planner (priority: 3)* Tokens: 38 in / 12645 out
Prevents malformed input from reaching OpenAI and wasting API credits.
All three generate endpoints (privacy-policy, terms-of-service,
data-processing-agreement) now validate businessId as UUID and
constrain clause ID arrays before any database or AI calls.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
feat: issue #402 create-a-zod-schema-for-the-apigenerate (agent task liancebot402)
Some checks failed
CI Quality Gate / Lint / Typecheck / Test / Build (pull_request) Has been cancelled
c6a63e554e
Some checks failed
CI Quality Gate / Lint / Typecheck / Test / Build (pull_request) Has been cancelled
This pull request has changes conflicting with the target branch.
  • .forgejo/workflows/ci.yml
  • bun.lock
  • package.json
  • packages/api/package.json
  • packages/api/src/db/schema.ts
  • packages/api/src/index.ts
  • packages/api/src/middleware/rate-limit.ts
  • packages/api/src/middleware/security-headers.ts
  • packages/api/src/routes/generate-tos.ts
  • packages/api/src/routes/generate.ts
  • packages/api/src/routes/health.ts
  • packages/api/src/routes/questionnaire.ts
  • packages/api/src/services/document-generator.ts
  • packages/api/src/services/llm.ts
  • packages/api/src/templates/index.ts
  • packages/api/tsconfig.json
  • packages/shared/src/types.ts
  • packages/web/src/app/questionnaire/page.tsx
  • packages/web/src/components/documents/DocumentList.tsx
  • packages/web/src/components/questionnaire/ReviewStep.tsx
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/zod-generate-validation:feat/zod-generate-validation
git switch feat/zod-generate-validation
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot!409
No description provided.