docs(custom-validation): fix misleading setInvalid usage and clarify limitations [DX-1077]#10977
Merged
Lisa White (whitelisab) merged 1 commit intoMay 13, 2026
Conversation
…limitations Remove cross-field setInvalid calls that silently do nothing, and update the README to explain that setInvalid is visual-only and same-field-only. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 task
Jared Jolton (jjolton-contentful)
approved these changes
May 13, 2026
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.
Purpose
The
custom-validationexample has been callingsdk.entry.fields['slug'].getForLocale(...).setInvalid()from within a different field's location — a pattern that silently does nothing. This has caused confusion for multiple developers (#3992), who expected the call to show a visual error indicator on the slug field.Two related limitations were not documented anywhere in the example:
setInvalidis visual only — it adds/removes the red error bar but does not prevent publishingsetInvalidonly affects the field the app is assigned to — cross-field calls are no-opsApproach
Field.tsx: Removed the two cross-fieldsetInvalidcalls. The publish-blocking logic (sdk.field.setValue('true'/'false')) was already correct and is unchanged — this just removes the dead code that was misleading readers.README.md: Updated the description ofsetInvalidto correctly describe it as a visual-only, same-field-only indicator, and explicitly points readers to thesetValuepattern for preventing publishing.No functional behavior changes — this is documentation and example cleanup only.
Testing steps
npx create-contentful-app --example custom-validationvalidationshort-text field (must equal"true") per the READMEvalidationfield via the Appearance tabBreaking Changes
None.
Dependencies and/or References
doc-appandui-extensions-sdkwill add the same clarifications to the developer docs and SDK type definitionsDeployment
N/A — example and documentation changes only.