Skip to content

docs(custom-validation): fix misleading setInvalid usage and clarify limitations [DX-1077]#10977

Merged
Lisa White (whitelisab) merged 1 commit into
masterfrom
fix/update-custom-validation-example-dx-1077
May 13, 2026
Merged

docs(custom-validation): fix misleading setInvalid usage and clarify limitations [DX-1077]#10977
Lisa White (whitelisab) merged 1 commit into
masterfrom
fix/update-custom-validation-example-dx-1077

Conversation

@whitelisab
Copy link
Copy Markdown
Contributor

@whitelisab Lisa White (whitelisab) commented May 13, 2026

Purpose

The custom-validation example has been calling sdk.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:

  • setInvalid is visual only — it adds/removes the red error bar but does not prevent publishing
  • setInvalid only affects the field the app is assigned to — cross-field calls are no-ops

Approach

  • Field.tsx: Removed the two cross-field setInvalid calls. 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 of setInvalid to correctly describe it as a visual-only, same-field-only indicator, and explicitly points readers to the setValue pattern for preventing publishing.

No functional behavior changes — this is documentation and example cleanup only.

Testing steps

  1. Bootstrap the example: npx create-contentful-app --example custom-validation
  2. Set up the content type with a validation short-text field (must equal "true") per the README
  3. Assign the app to the validation field via the Appearance tab
  4. Enter an invalid slug format — confirm the error message renders in the app UI
  5. Confirm the entry cannot be published while the slug is invalid
  6. Fix the slug format — confirm the entry publishes successfully
  7. Confirm no red error bar appears on the slug field (the old misleading behavior is gone)

Breaking Changes

None.

Dependencies and/or References

  • Closes #3992
  • DX-1077
  • Related: companion PRs in doc-app and ui-extensions-sdk will add the same clarifications to the developer docs and SDK type definitions

Deployment

N/A — example and documentation changes only.

…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>
@whitelisab Lisa White (whitelisab) merged commit eb062f2 into master May 13, 2026
16 checks passed
@whitelisab Lisa White (whitelisab) deleted the fix/update-custom-validation-example-dx-1077 branch May 13, 2026 20:27
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.

[examples/custom-validation] Set fields to invalid incorrect behaviour

2 participants