Skip to content

feat: add validation for contact form input fields - #74

Open
om-dev007 wants to merge 1 commit into
Jyotibrat:mainfrom
om-dev007:fix/issue-72-add-input-validation
Open

feat: add validation for contact form input fields#74
om-dev007 wants to merge 1 commit into
Jyotibrat:mainfrom
om-dev007:fix/issue-72-add-input-validation

Conversation

@om-dev007

Copy link
Copy Markdown
Contributor

Description

This PR improves server-side validation for the contact form endpoint by validating the submitted input before processing email requests.

Changes Made

  • Added email format validation using a regular expression.

  • Added minimum and maximum length validation for the name field.

  • Added minimum and maximum length validation for the subject field.

  • Added minimum and maximum length validation for the message field.

  • Trimmed user input before validation and email processing.

  • Returns 400 Bad Request with descriptive error messages for invalid input.

  • Reused validated values when composing the email.

Validation Rules

Field | Validation -- | -- Name | Required, trimmed, 2–50 characters Email | Required, valid email format Subject | Required, trimmed, 5–100 characters Message | Required, trimmed, 10–1000 characters

Benefits

  • Prevents malformed or invalid submissions.

  • Improves data quality before sending emails.

  • Reduces unnecessary email processing.

  • Provides clearer feedback to users.

  • Maintains backward compatibility with the existing endpoint.

Testing

  • ✅ Verified valid requests are processed successfully.

  • ✅ Verified invalid email addresses return 400 Bad Request.

  • ✅ Verified empty or whitespace-only fields are rejected.

  • ✅ Verified name, subject, and message length constraints.

  • ✅ Confirmed email sending functionality remains unchanged.

Closes #72

@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

@om-dev007 is attempting to deploy a commit to the Bindupautra Jyotibrat's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Jyotibrat
Jyotibrat self-requested a review July 1, 2026 05:51
@Jyotibrat Jyotibrat added enhancement New feature or request SSoC26 Label for issues raised by a contributor during the open source Social Summer of Code 2026. Medium Issue which is bit difficult to resolve as compared to easy. labels Jul 1, 2026
@Jyotibrat Jyotibrat added this to AI Flow Jul 1, 2026
@Jyotibrat Jyotibrat moved this to Open PR in AI Flow Jul 1, 2026
@om-dev007

Copy link
Copy Markdown
Contributor Author

Hi @Jyotibrat,
I've addressed issue #72 by adding server-side validation for all contact form fields, including email format validation, length checks, and input trimming while keeping the existing functionality intact.
The only failing checks are Vercel deployment checks, which appear to require repository authorization from the project owner. The code changes themselves are complete, and the security check has passed successfully.
Whenever you have time, I'd appreciate it if you could review the PR. Thank you!

@Jyotibrat

Copy link
Copy Markdown
Owner

Hi @Jyotibrat, I've addressed issue #72 by adding server-side validation for all contact form fields, including email format validation, length checks, and input trimming while keeping the existing functionality intact. The only failing checks are Vercel deployment checks, which appear to require repository authorization from the project owner. The code changes themselves are complete, and the security check has passed successfully. Whenever you have time, I'd appreciate it if you could review the PR. Thank you!

I'll review the PR and get back to you

@om-dev007

Copy link
Copy Markdown
Contributor Author

@Jyotibrat ok thank you for giving your valuable time

@Jyotibrat Jyotibrat left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend logic works perfectly fine. But, can you add the response to the frontend so that the user knows what is wrong with the message that he/she is typing.

Thank You for your contribution @om-dev007 .

@om-dev007

Copy link
Copy Markdown
Contributor Author

Hi @Jyotibrat,
Thank you for the review and feedback.
The current PR was focused on adding server-side validation for the contact form fields as described in issue #72. The backend now returns specific validation error messages for invalid input.
Since showing those validation messages in the UI would require frontend changes as well, I wanted to confirm whether you would like that to be included as part of this PR, or handled in a separate follow-up issue/PR.
I can proceed accordingly. Thank you!

@Jyotibrat

Copy link
Copy Markdown
Owner

Hi @Jyotibrat, Thank you for the review and feedback. The current PR was focused on adding server-side validation for the contact form fields as described in issue #72. The backend now returns specific validation error messages for invalid input. Since showing those validation messages in the UI would require frontend changes as well, I wanted to confirm whether you would like that to be included as part of this PR, or handled in a separate follow-up issue/PR. I can proceed accordingly. Thank you!

Raise a separate issue for that and I will assign it to you. Once your frontend PR will be raised then I will check both backend and frontend PR together and merged it if it works.

@om-dev007

Copy link
Copy Markdown
Contributor Author

Hi @Jyotibrat,
Thank you for the clarification.
At the moment, I won’t be able to take up the frontend follow-up issue/PR, so please feel free to assign it to someone else if needed.
If the backend validation changes in this PR are still useful on their own, I’d be happy for them to be considered separately. Otherwise, I completely understand if you’d prefer to review/merge both together after the frontend work is completed.
Thanks again for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Medium Issue which is bit difficult to resolve as compared to easy. SSoC26 Label for issues raised by a contributor during the open source Social Summer of Code 2026.

Projects

Status: Open PR

Development

Successfully merging this pull request may close these issues.

Add input validation for contact form fields

2 participants