Skip to content

Fix(validation): exclude currently editing entity from unique checks#719

Merged
buckhalt merged 2 commits intonextfrom
fix/unique-validation-self-match
Apr 22, 2026
Merged

Fix(validation): exclude currently editing entity from unique checks#719
buckhalt merged 2 commits intonextfrom
fix/unique-validation-self-match

Conversation

@buckhalt
Copy link
Copy Markdown
Member

Fixes bug where current entity value was causing unique validation to fail against itself.

Adds currentEntityId to ValidationContext and threads it through collectNetworkValues. Used from NodeForm and SlidesForm.

fixes bug where current entity value was causing unique validation to fail
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a validation bug where unique checks would fail while editing an existing entity because the entity’s current value was compared against itself. This adds a currentEntityId to the validation context and uses it to exclude the currently edited entity from the “existing values” set.

Changes:

  • Extend ValidationContext with currentEntityId and thread it through useProtocolForm from NodeForm and SlidesForm.
  • Update collectNetworkValues / unique validation to exclude the current entity from uniqueness comparisons.
  • Add unit tests covering unique validation while editing.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/interviewer/Interfaces/SlidesForm/SlidesForm.tsx Passes the edited item’s id into useProtocolForm for context-aware validation.
lib/interviewer/Interfaces/NameGenerator/components/NodeForm.tsx Passes selected node id into useProtocolForm so unique won’t match against itself.
lib/form/validation/utils/collectNetworkValues.ts Adds an optional exclusion id and filters entities accordingly.
lib/form/validation/functions.ts Threads currentEntityId into unique validation via collectNetworkValues.
lib/form/validation/functions.test.ts Adds tests ensuring unique ignores the currently edited entity but still rejects duplicates from others.
lib/form/store/types.ts Extends ValidationContext with currentEntityId?: string.
lib/form/hooks/useProtocolForm.tsx Merges currentEntityId into validation context for fields generated from protocol forms.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/form/hooks/useProtocolForm.tsx Outdated
@github-actions
Copy link
Copy Markdown

❌ E2E tests — failure

📊 View report

@github-actions
Copy link
Copy Markdown

❌ E2E tests — failure

📊 View report

@github-actions
Copy link
Copy Markdown

❌ E2E tests — failure

📊 View report

@github-actions
Copy link
Copy Markdown

❌ E2E tests — failure

📊 View report

@github-actions
Copy link
Copy Markdown

✅ E2E tests — success

📊 View report

@buckhalt buckhalt marked this pull request as ready for review April 22, 2026 20:15
@buckhalt buckhalt merged commit 6f1f7ed into next Apr 22, 2026
19 of 23 checks 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