Skip to content

Conversation

@zbeyens
Copy link
Member

@zbeyens zbeyens commented Sep 29, 2025

Summary

  • Fixes validation error when beforeCreate hooks try to add required fields
  • Makes all input fields optional using partial() for the create mutation
  • Allows beforeCreate hooks to properly add/modify required fields like username

Problem

The create mutation's input validator was requiring all schema fields to be present before the beforeCreate hook could run. This caused validation errors when beforeCreate hooks tried to add required fields (like auto-generating usernames).

Solution

Used partial() from convex-helpers to make all input fields optional during the validation phase. The actual schema validation still happens when inserting into the database, maintaining data integrity.

Test plan

  • beforeCreate hooks can now add required fields without validation errors
  • Database constraints are still enforced after hooks run
  • Existing create operations continue to work

🤖 Generated with Claude Code

Previously, the create mutation's input validator required all schema fields,
causing validation errors when beforeCreate hooks tried to add required fields.

This change uses partial() to make all input fields optional during validation,
allowing beforeCreate hooks to add or modify any required fields. The actual
schema validation still occurs when inserting into the database.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@changeset-bot
Copy link

changeset-bot bot commented Sep 29, 2025

🦋 Changeset detected

Latest commit: bdb2151

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
better-auth-convex Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@zbeyens zbeyens merged commit 49da79b into main Sep 29, 2025
1 check passed
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