Skip to content

CC-49: Fix how forced values are applied in forms#325

Merged
ianpaschal merged 3 commits into
mainfrom
ian/cc-49-single-match-is-invalid-input
May 12, 2026
Merged

CC-49: Fix how forced values are applied in forms#325
ianpaschal merged 3 commits into
mainfrom
ian/cc-49-single-match-is-invalid-input

Conversation

@ianpaschal
Copy link
Copy Markdown
Owner

@ianpaschal ianpaschal commented May 12, 2026

Fixes CC-49

Summary by CodeRabbit

  • New Features

    • Enhanced form validation error display in player field selection.
  • Bug Fixes

    • Improved form error handling and clearing during submission.
    • Refined schema validation for player fields to require either user selection or placeholder.
  • Style

    • Removed player section headers from match result form layout.

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
combat-command Ready Ready Preview, Comment May 12, 2026 5:25pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 914bc012-eabd-4dc2-a96e-75c61113a12c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This PR refactors form validation across the application by introducing a form handle pattern to replace react-hook-form's typed setError function. The core validateForm utility now accepts a form object with clearErrors() and setError() methods, enabling better error lifecycle management. Multiple form components switch from object spread to lodash deep merge for composing default values. MatchResultForm receives new schema validation rules requiring player user ID or placeholder, removes header markup, and PlayerField gains inline error display with new styles. The pattern is consistently applied across eight form components.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is minimal and only references the issue ticket (CC-49) without explaining what the PR does or why changes were made. Expand the description to explain the main changes (forced value merging strategy, validateForm refactoring) and the problem being solved.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: refactoring how forced values are applied across multiple form components by switching from spread operators to lodash.merge.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ian/cc-49-single-match-is-invalid-input

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Copy Markdown

@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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/MatchResultForm/MatchResultForm.tsx`:
- Line 124: The validateForm call is building the schema from the unmerged
formData so forcedValues (e.g., forcedValues.gameSystem) can be ignored; first
merge the data (merge({}, formData, forcedValues)) into a single variable (e.g.,
mergedData) and then call createSchema(mergedData.gameSystem) and validateForm
with that schema and mergedData
(validateForm(createSchema(mergedData.gameSystem), mergedData, form)) so
validation runs against the correct, post-merge game-system schema.

In `@src/utils/validateForm.ts`:
- Line 15: The duplicate call to clearErrors() is redundant—remove the extra
invocation from validateForm by deleting the form.clearErrors() line inside the
validateForm function so only the Form component's clearErrors() (in Form.tsx)
remains; locate the validateForm function and the form.clearErrors() call and
remove that single call to avoid double-clearing while keeping the Form.tsx
clearErrors() behavior intact.
- Around line 5-8: The FormHandle interface currently uses a plain string for
field names which loses type safety; update the interface (FormHandle) to be
generic (e.g., FormHandle<T>) and change setError to accept the typed field path
used by react-hook-form (use the library's FieldPath/Path utility for the name
parameter and the appropriate FieldError-like error type) while keeping
clearErrors unchanged; update all usages/call sites to pass the form data type
to FormHandle so invalid field names are caught at compile time.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 36cf5459-f260-4768-91ae-7ca219bee87f

📥 Commits

Reviewing files that changed from the base of the PR and between 1dd0e9f and db9604a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (18)
  • package.json
  • src/components/ChangeEmailForm/ChangeEmailForm.tsx
  • src/components/ChangePasswordForm/ChangePasswordForm.tsx
  • src/components/ListCommentForm/ListCommentForm.tsx
  • src/components/ListForm/ListForm.tsx
  • src/components/MatchResultForm/MatchResultForm.module.scss
  • src/components/MatchResultForm/MatchResultForm.schema.ts
  • src/components/MatchResultForm/MatchResultForm.tsx
  • src/components/MatchResultForm/components/PlayerField/PlayerField.module.scss
  • src/components/MatchResultForm/components/PlayerField/PlayerField.tsx
  • src/components/MatchResultProvider/actions/useCreateAction.tsx
  • src/components/MatchResultProvider/components/MatchResultPhotoForm/MatchResultPhotoForm.tsx
  • src/components/TournamentCompetitorForm/TournamentCompetitorForm.tsx
  • src/components/TournamentForm/TournamentForm.tsx
  • src/components/TournamentPairingConfigForm/TournamentPairingConfigForm.tsx
  • src/components/TournamentRegistrationForm/TournamentRegistrationForm.tsx
  • src/components/generic/Form/Form.tsx
  • src/utils/validateForm.ts
💤 Files with no reviewable changes (1)
  • src/components/MatchResultForm/MatchResultForm.module.scss

Comment thread src/components/MatchResultForm/MatchResultForm.tsx Outdated
Comment thread src/utils/validateForm.ts Outdated
Comment thread src/utils/validateForm.ts
@ianpaschal ianpaschal merged commit d5ceda5 into main May 12, 2026
3 checks passed
@ianpaschal ianpaschal deleted the ian/cc-49-single-match-is-invalid-input branch May 12, 2026 17:32
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.

1 participant