Feature/integrate zod for request validation#334
Open
AnandAyush005 wants to merge 10 commits into
Open
Conversation
…ns, concept explanations, and interview tips
Contributor
Author
|
ECSoC26 |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 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
How Has This Been Tested?
Describe the testing steps performed.
Sent valid requests to each route → confirmed successful execution.
Sent invalid requests (missing fields, wrong types, empty arrays) → confirmed proper 400 Validation failed responses.
Verified error messages are clear and field‑specific.
Checked that controllers no longer need manual if (!field) checks.
Checklist