Skip to content

Feature/integrate zod for request validation#334

Open
AnandAyush005 wants to merge 10 commits into
Canopus-Labs:mainfrom
AnandAyush005:feature/integrate-zod-for-request-validation
Open

Feature/integrate zod for request validation#334
AnandAyush005 wants to merge 10 commits into
Canopus-Labs:mainfrom
AnandAyush005:feature/integrate-zod-for-request-validation

Conversation

@AnandAyush005

@AnandAyush005 AnandAyush005 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

📝 Pull Request Description

Related Issue

Closes #321

Summary

This PR introduces Zod‑based input validation across multiple backend routes, replacing ad‑hoc checks and Joi usage.
Key improvements:

  • Added Zod schemas and middlewares for AI routes (generate-questions, generate-explanation, generate-tips).

  • Added Zod validators for Question routes (add, pin, note).

  • Added Zod validators for Resume routes (compile, analyze, save).

  • Added Zod validators for Session routes (create, get by ID, delete).

  • Added Zod validators for UserSheetProgress routes (save, get by sheetId).

  • Unified error handling with consistent JSON responses (success: false, message: "Validation failed", errors: [...]).

This ensures all incoming requests are validated before hitting MongoDB or external services, improving reliability, security, and developer experience.


Type of Change

  • ✨ New feature
  • ♻️ Refactoring

How Has This Been Tested?

Describe the testing steps performed.

  1. Sent valid requests to each route → confirmed successful execution.

  2. Sent invalid requests (missing fields, wrong types, empty arrays) → confirmed proper 400 Validation failed responses.

  3. Verified error messages are clear and field‑specific.

  4. Checked that controllers no longer need manual if (!field) checks.


Checklist

  • My code follows the project's guidelines
  • I have tested my changes
  • I have linked the related issue
  • My changes do not introduce new warnings or errors

@AnandAyush005

Copy link
Copy Markdown
Contributor Author

ECSoC26

@AnandAyush005

Copy link
Copy Markdown
Contributor Author

Hi, @KaranUnique can you please review my PR, i have just added middleware zod, and make the controller to perform only logical tasks , and also reduces the redundancy of code some places where i think it should be, try to review this PR as soon as possible then, if there any further improvement on your suggestion then i will add that asap.

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.

[Feature]: integrate Zod for request validation

1 participant