Skip to content

Backend] Implement Request Validation Middleware (Joi/Zod) (Apertre3.0) #50

@Aditya-18849

Description

@Aditya-18849

Description: Currently, the backend controllers likely perform manual checks for req.body properties (e.g., checking if email exists inside the controller), or worse, assume the data is correct. This leads to code duplication, potential server crashes due to undefined properties, and inconsistent error messages for the frontend.

To improve security and code maintainability, we should implement a robust validation layer that intercepts requests before they reach the controller logic.

Proposed Solution: Integrate a schema validation library (recommend Joi or Zod) and create a reusable middleware function. This middleware will validate the incoming request body against a defined schema and return a 400 Bad Request with clear error details if validation fails.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions