Fix(validation): exclude currently editing entity from unique checks#719
Merged
Fix(validation): exclude currently editing entity from unique checks#719
Conversation
fixes bug where current entity value was causing unique validation to fail
|
Contributor
There was a problem hiding this comment.
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
ValidationContextwithcurrentEntityIdand thread it throughuseProtocolFormfromNodeFormandSlidesForm. - Update
collectNetworkValues/uniquevalidation 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.
|
❌ E2E tests — failure |
|
❌ E2E tests — failure |
|
❌ E2E tests — failure |
|
❌ E2E tests — failure |
|
✅ E2E tests — success |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes bug where current entity value was causing unique validation to fail against itself.
Adds
currentEntityIdtoValidationContextand threads it throughcollectNetworkValues. Used fromNodeFormandSlidesForm.