Skip to content

feat(backend): add Zod server-side validation for task creation (#66)#116

Merged
Abd-Standard merged 2 commits into
Core-Foundry:mainfrom
julianvillalba688:feat/issue-66-input-validation
Jul 21, 2026
Merged

feat(backend): add Zod server-side validation for task creation (#66)#116
Abd-Standard merged 2 commits into
Core-Foundry:mainfrom
julianvillalba688:feat/issue-66-input-validation

Conversation

@julianvillalba688

Copy link
Copy Markdown
Contributor

Description

This PR addresses the security vulnerability where task creation relied exclusively on client-side validation. I have implemented a rigorous server-side validation layer inside the Next.js API route using Zod to sanitize required fields, enforce valid reward limits, and ensure future-date deadlines before any interaction with the ledger client happens.

Closes #66

Changes Made

  1. Zod Validation Schema (src/lib/taskValidation.ts):
    • Engineered a strict taskSchema enforcing field types, minimum string lengths (title >= 5, description >= 10), explicit positive boundary checks for rewards (> 0), and dynamic future timestamp constraints for deadlines.
  2. API Endpoint Pipeline (src/app/api/tasks/route.ts):
    • Built a secure POST endpoint that safe-parses incoming client JSON against the Zod schema.
    • Structured error normalization to catch failures and format field-specific feedback using .issues, responding with a clean 400 Bad Request payload.
  3. Robust Unit Tests (src/lib/taskValidation.test.ts):
    • Formulated an exhaustive testing matrix via Vitest validating: the happy path, fields omitted/missing, out-of-bounds zero/negative rewards, and elapsed deadlines.
  4. Build Fix (src/components/Navbar.tsx):
    • Patched an inherited compilation barrier regarding duplicated attributes in the Navbar layout, unblocking successful production bundles.

Verification Matrix

  • Vitest Pipeline: All validation tests execute and pass cleanly.
  • Production Build: Next.js optimized production build succeeds with zero linter or TypeScript type check alerts.

@Abd-Standard
Abd-Standard merged commit 06ff0db into Core-Foundry:main Jul 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Input Validation for Task Creation

2 participants