Skip to content

Conversation

erik-arne
Copy link
Collaborator

@erik-arne erik-arne commented Oct 14, 2025

Overview: This PR updates the inviteMemberSchema in src/actions/collaboration.ts to include a required email field and exports its inferred input type.

Changes

  • Added email: z.string().email().nonempty() to the inviteMemberSchema.
  • Ensured inviteMemberSchema is exported for broader use.
  • Introduced export type InviteMemberInput = z.infer<typeof inviteMemberSchema> for type safety in handlers and UI components.
  • These changes improve data validation and type inference for member invitation workflows.

Summary by CodeRabbit

  • Bug Fixes
    • Invitation form now requires a valid, non-empty email address, preventing empty or malformed inputs.
    • Improves reliability of member invitations by validating input before submission.
    • Provides clearer error feedback when an invalid email is entered.

@coderabbitai
Copy link

coderabbitai bot commented Oct 14, 2025

Walkthrough

Adds email validation to inviteMember input schema, exports a new InviteMemberInput type inferred from the schema, and maintains the inviteMember function’s behavior to check user existence and create a project member. Changes are contained to src/actions/collaboration.ts.

Changes

Cohort / File(s) Summary
Collaboration actions and types
src/actions/collaboration.ts
Added email().nonempty() to inviteMemberSchema; introduced exported type InviteMemberInput inferred from the schema; inviteMember continues to validate input, verify user existence, and create a project member.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant Actions as CollaborationActions
  participant Schema as Validation (schema)
  participant Users as UserRepo
  participant Members as ProjectMemberRepo

  Client->>Actions: inviteMember(input with email)
  Actions->>Schema: validate input (email nonempty)
  alt Invalid input
    Schema-->>Actions: ValidationError
    Actions-->>Client: Error (invalid email)
  else Valid input
    Actions->>Users: findUserByEmail(input.email)
    alt User found
      Users-->>Actions: User
      Actions->>Members: createProjectMember(user, projectId, role)
      Members-->>Actions: Member
      Actions-->>Client: Success (member created)
    else User not found
      Users-->>Actions: null
      Actions-->>Client: Error (user not found)
    end
  end

  rect rgba(200, 230, 255, 0.25)
  note right of Schema: New: email().nonempty() validation<br/>applied at schema boundary
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • fehranbit

Poem

I hop through code with whiskers bright,
A new email check to guide the night.
Invite typed neat, inputs tight—
Members join with proper rite.
Thump-thump, ship it light—
Bugs beware my carrot bite! 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly describes the key updates: adding the email validation field to the invite member schema and exporting the corresponding input type, which align directly with the changes in collaboration.ts. It is concise, specific to the main functionality change, and avoids unnecessary details. A teammate reviewing history can immediately understand the primary purpose of this PR.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-email-to-invite-member-schema

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/actions/collaboration.ts (1)

8-8: Remove redundant .nonempty() validator.

The .email() validator already ensures the string is non-empty and properly formatted. The chained .nonempty() is redundant and deprecated in Zod v3.

Apply this diff to simplify the validation:

-  email: z.string().email().nonempty(),
+  email: z.string().email(),
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8e376e and 59b9723.

📒 Files selected for processing (1)
  • src/actions/collaboration.ts (1 hunks)
🔇 Additional comments (1)
src/actions/collaboration.ts (1)

12-13: LGTM! Good practice to export the inferred type.

Exporting InviteMemberInput enables type safety for UI components and other consumers of this schema. This follows TypeScript and Zod best practices.

@fehranbit
Copy link
Member

Nice, adding that email validation will definitely help avoid messy inputs! 👍

@fehranbit fehranbit merged commit cf214b7 into main Oct 14, 2025
1 of 2 checks passed
@fehranbit fehranbit deleted the feat/add-email-to-invite-member-schema branch October 14, 2025 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants