Skip to content

Add Request Validation Middleware (e.g. Zod) #5

@greatest0fallt1me

Description

@greatest0fallt1me

Description
Introduce request validation using a schema library (e.g. Zod): validate query, params, and body for selected routes. Return 400 with validation errors in a consistent format when validation fails.

Requirements and context

  • Must validate input before business logic
  • Return clear error messages for invalid fields
  • Reusable validator middleware (e.g. validate(schema))

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b feature/request-validation
  • Implement changes
    • Add zod (or similar) dependency
    • Add src/middleware/validate.ts: accept schema(s), validate req.body/query/params, next() or pass errors to error handler
    • Apply to one or two existing routes as example
  • Test and commit
    • Test with invalid payload and verify 400 and error shape
    • Example commit message: feat: request validation middleware with zod

Guidelines

  • Consistent validation error format
  • Clear documentation
  • Timeframe: 96 hours
  • Project details: #

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave program

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions