Implement request validation middleware for the authentication routes (/register and /login) to ensure incoming request bodies are properly validated before reaching the controllers.
What Needs to Be Done:
Add a validation library (e.g., Joi or Zod).
Create reusable validation middleware.
Validate required fields:
Register: email (valid format), password (minimum length).
Login: email and password.
Return a structured 400 Bad Request response for invalid input.
Ensure no changes break existing authentication flow.
The goal is to move validation logic out of controllers and enforce clean, production-safe input handling.
Implement request validation middleware for the authentication routes (/register and /login) to ensure incoming request bodies are properly validated before reaching the controllers.
What Needs to Be Done:
Add a validation library (e.g., Joi or Zod).
Create reusable validation middleware.
Validate required fields:
Register: email (valid format), password (minimum length).
Login: email and password.
Return a structured 400 Bad Request response for invalid input.
Ensure no changes break existing authentication flow.
The goal is to move validation logic out of controllers and enforce clean, production-safe input handling.