Skip to content

Filter error keywords before touch#2540

Merged
sdirix merged 4 commits intoeclipsesource:masterfrom
kchobantonov:filter-error-keywords-before-touch
Feb 11, 2026
Merged

Filter error keywords before touch#2540
sdirix merged 4 commits intoeclipsesource:masterfrom
kchobantonov:filter-error-keywords-before-touch

Conversation

@kchobantonov
Copy link
Contributor

@kchobantonov kchobantonov commented Jan 24, 2026

A new configuration option, filterErrorKeywordsBeforeTouch, allows selective suppression of validation errors before a control is touched, based on AJV error keywords.

This option exists because in most real-world forms, only certain errors—most commonly required—should be hidden prior to user interaction. Other validation errors (such as minLength, pattern, or format) often provide useful guidance and should remain visible immediately.

Instead of hiding all validation errors before interaction, you can now explicitly choose which error types are suppressed and which are shown.

This option is only applied when enableFilterErrorsBeforeTouch is enabled.
If enableFilterErrorsBeforeTouch is false, filterErrorKeywordsBeforeTouch has no effect and all validation errors are shown immediately.

If enableFilterErrorsBeforeTouch is true and filterErrorKeywordsBeforeTouch is not provided, the default behavior applies: no validation errors are shown before the control is touched.

Once the control is touched, all validation errors are always displayed, regardless of these settings.

@netlify
Copy link

netlify bot commented Jan 24, 2026

Deploy Preview for jsonforms-examples ready!

Name Link
🔨 Latest commit 218a80d
🔍 Latest deploy log https://app.netlify.com/projects/jsonforms-examples/deploys/698c0fe343a93200089094f5
😎 Deploy Preview https://deploy-preview-2540--jsonforms-examples.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kchobantonov
Copy link
Contributor Author

@sdirix @lucas-koehler please review this PR. In the demo app there is a new settings to provide the new config setting which by default is set to an array of one element which is - "required"

@coveralls
Copy link

coveralls commented Jan 27, 2026

Coverage Status

coverage: 82.798%. remained the same
when pulling 218a80d on kchobantonov:filter-error-keywords-before-touch
into befd0ae on eclipsesource:master.

Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

@kchobantonov Thanks for your PR ❤️

For the future I would prefer if you could open more granular PRs. One reason some of your PRs take longer to be merged is because they often span multiple topics. For example if this PR would just contain the location changes, it could have been merged already.

We prefer smaller PRs, separated by topic, if possible.

@kchobantonov
Copy link
Contributor Author

@kchobantonov Thanks for your PR ❤️

For the future I would prefer if you could open more granular PRs. One reason some of your PRs take longer to be merged is because they often span multiple topics. For example if this PR would just contain the location changes, it could have been merged already.

We prefer smaller PRs, separated by topic, if possible.

Yes I understand that but while I was fixing this I noticed the issues with the location and I didn't want to create yet another PR

@kchobantonov kchobantonov requested a review from sdirix February 11, 2026 05:15
@kchobantonov
Copy link
Contributor Author

@sdirix all are fixed except for the useJsonForms() which in another PR as I said I moved that to the vue project - will resolve conflicts once some of those PRs are merged

Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

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

Works for me, thanks for the changes.

Comment on lines +200 to +224
const errorsAtControl =
jsonforms.core?.errors?.filter(
(error) => input.control.value.path === getControlPath(error),
) ?? [];

// Filter out errors that match the filterKeywords, keep the rest
const errorsToShow = errorsAtControl.filter(
(error) => !error.keyword || !filterKeywords.includes(error.keyword),
);
// If no errors were filtered out (all errors remain), return original errors string
if (errorsToShow.length === errorsAtControl.length) {
return input.control.value.errors;
}

const t = getTranslator()({ jsonforms });
const te = getErrorTranslator()({ jsonforms });

return getCombinedErrorMessage(
errorsToShow,
te,
t,
input.control.value.schema,
input.control.value.uischema,
input.control.value.path,
);
Copy link
Member

Choose a reason for hiding this comment

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

We can't change it in this PR but this is a topic for a potential JSON Forms 4.0. We basically repeat what the core mappers do because we need to customize their behavior. The mappers are too feature rich and should be more modular.

@sdirix sdirix merged commit e3d804d into eclipsesource:master Feb 11, 2026
8 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.

3 participants