Skip to content

refactor(calendar): extract validation logic into a separate layer #313

@allenhutchison

Description

@allenhutchison

Context

From PR #308 review feedback by @abhipatel12:

The validations here make sense. At some point it may make sense to have a validation layer to separate all this logic to make it easier to read.

Problem

CalendarService.createEvent and updateEvent have accumulated significant inline validation logic:

  • start/end dateTime vs date exclusivity checks
  • eventType-specific constraints (focusTime/outOfOffice can't be all-day)
  • workingLocationProperties required sub-property validation
  • summary requirements based on eventType
  • ISO 8601 datetime format validation
  • Email format validation

This makes the methods harder to read and the validation harder to reuse or test independently.

Proposal

Extract calendar event validation into a dedicated module (e.g. CalendarValidation.ts) that:

  • Consolidates all input validation for createEvent and updateEvent
  • Returns structured validation errors
  • Can be unit tested independently of the service
  • Keeps the service methods focused on API interaction logic

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions