Fix: enforce email validation on registration- Enforce email format v… - #205
Merged
Premshaw23 merged 1 commit intoMay 20, 2026
Merged
Conversation
…erification using EMAIL_PATTERN in the register API route- Return 400 Bad Request early if validation fails, preventing database insertion- Add targeted unit tests for standard valid/invalid email formats- Closes Premshaw23#167
Contributor
|
@omnipotentchaos is attempting to deploy a commit to the Prem Shaw's projects Team on Vercel. A member of the Team first needs to authorize it. |
Premshaw23
approved these changes
May 20, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR closes #167 by enforcing the existing EMAIL_PATTERN in the registration API route so invalid email formats are rejected early (before DB connection / blob upload), and adds Jest coverage to prevent regressions.
Changes:
- Added an
EMAIL_PATTERN.test(email)guard inPOST /api/registerthat returns400with"Invalid email address". - Added Jest tests covering a successful registration with a valid email (including sub-addressing) and multiple invalid email formats, asserting that invalid input does not reach DB operations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| app/api/register/route.js | Adds early email-format validation using the pre-declared EMAIL_PATTERN to block invalid registrations before DB work. |
| components/tests/registerRoute.test.js | Adds unit tests validating 201 success for valid emails and 400 rejection for invalid formats, including ensuring DB is not contacted on invalid input. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
|
Done 👍 |
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.
What type of PR is this?
Description
Enforces the pre-declared
EMAIL_PATTERNin the register endpoint to ensure only valid email formats are processed and stored in the database. Previously, the validation pattern was declared but not used, allowing invalid emails to bypass verification.Related Issues
Closes #167
Changes Made
EMAIL_PATTERN.test(email)check inapp/api/register/route.jsto reject invalid email formats.400 Bad Requestand message"Invalid email address"if validation fails, preventing any file upload or database operations.components/_tests_/registerRoute.test.jsto add comprehensive Jest unit tests covering valid emails (like sub-addressed emails e.g.user+tag@domain.co.uk) and multiple invalid formats.Testing
How did you test these changes?
Screenshots (if applicable)
N/A (Backend API validation and test suite enhancements)
Checklist
.env.localis not committednpm run build)