Skip to content

Consider extracting shared base validator for conversation validators #41

Closed

Description

@larryro

Summary

conversationItemValidator and conversationWithMessagesValidator have identical structures. Consider extracting a shared base validator to reduce duplication.

Context

Identified during PR #37 review (CodeRabbit comment #2652223407).

Current State

Both validators in services/platform/convex/model/conversations/validators.ts have identical field definitions, which violates DRY principle.

Considerations

Keep Separate (Current Decision)

  • Semantic separation: list view vs detail view
  • Allows future divergence if views need different fields
  • List view might later omit computed fields for performance

Extract Base Validator

const conversationBaseFields = {
  _id: v.id('conversations'),
  _creationTime: v.number(),
  // ... shared fields
};

export const conversationItemValidator = v.object({
  ...conversationBaseFields,
  // list-specific fields if any
});

export const conversationWithMessagesValidator = v.object({
  ...conversationBaseFields,
  // detail-specific fields if any
});

Recommendation

Monitor usage patterns. If these validators remain identical after several iterations, extract a shared base. If they diverge, the current separation is justified.

Priority

Low - This is a code organization improvement, not a bug fix.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions