Skip to content

Conversation

@hbjORbj
Copy link
Contributor

@hbjORbj hbjORbj commented Jan 26, 2026

What does this PR do?

This PR fixes a validation gap where phone numbers could be entered in optional email fields without any format validation, causing 500 errors during iCal generation and silent email sending failures.

Related to #27217 which fixes the error handling for this issue.

The Fix

In getBookingResponsesSchema.ts, email format validation now runs whenever a non-empty value is provided, even if the field is optional. This follows the same pattern already used for phone field validation:

const needsValidation =
  checkOptional || bookingField.required || (value && String(value).trim() !== "");

Since getBookingResponsesSchema is shared between frontend (useBookingForm.ts) and backend, this fix validates on both sides.

Context

When an event type has the email field configured as optional (phone-only bookings), users could enter a phone number in the email field. Neither frontend nor backend validated the email format for optional fields, which later caused:

  • Initial booking: Organizer doesn't receive confirmation email (fails silently)
  • Reschedule: Returns 500 error to user (booking succeeds but user sees error)

Tests Added

  1. "should validate email format even when email field is optional" - Creates a phone-only event type with optional email, enters a phone number in the email field, and expects a validation error.

  2. "should show validation error when phone number is entered in required email field" - Uses a default event type with required email field.

Both tests should now PASS with the validation fix.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - validation fix only.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

Run the e2e test:

PLAYWRIGHT_HEADLESS=1 yarn e2e apps/web/playwright/email-validation.e2e.ts

Expected results: Both tests should PASS.

Manual testing:

  1. Create a phone-only event type (email field optional, phone required)
  2. Book the event and enter a phone number in the email field
  3. Should see validation error "email_validation_error" preventing submission

Human Review Checklist

  • Verify empty optional email fields still work (no validation error when left empty)
  • Confirm the validation pattern matches the existing phone field validation logic
  • Check that e2e tests pass in CI

Checklist

  • My code follows the style guidelines of this project
  • I have checked if my changes generate no new warnings

Link to Devin run: https://app.devin.ai/sessions/cbaf3621d7f143688ae0ad35e196096a
Requested by: @hbjORbj

Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions
Copy link
Contributor

github-actions bot commented Jan 26, 2026

E2E results are ready!

@devin-ai-integration devin-ai-integration bot changed the title test: add e2e test demonstrating email validation gap in optional fields fix: validate email format for optional email fields Jan 26, 2026
@hbjORbj hbjORbj force-pushed the devin/1769431484-email-validation-e2e-test branch from 2f229bc to 0a171a2 Compare January 26, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants