react-jsonschema-form icon indicating copy to clipboard operation
react-jsonschema-form copied to clipboard

how to trigger validation only for fields that have changed when certain fields change?

Open DualWield opened this issue 1 year ago • 4 comments

Prerequisites

What theme are you using?

core

What is your question?

how to trigger validation only for fields that have changed when certain fields change?

DualWield avatar Jul 09 '24 10:07 DualWield

for example, when the field A changed, I only want to validate the field A.

DualWield avatar Jul 09 '24 10:07 DualWield

What's the problem you're trying to solve?

CarlosAmaral avatar Jul 12 '24 07:07 CarlosAmaral

Ajv validation is all-or-nothing, so off the top of my head, maybe you could keep track of which fields have been changed by the user, then use transformErrors to remove errors on all fields that have not been touched?

nickgros avatar Jul 12 '24 19:07 nickgros

@DualWield To add to @nickgros comment, the onChange() handler is sent the id of the field on which a change occurred (if there is no id then likely it is change done to add default values).

heath-freenome avatar Jul 12 '24 20:07 heath-freenome

This issue has been automatically marked as possibly close because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you.

stale[bot] avatar Oct 11 '25 20:10 stale[bot]

This issue was closed because of lack of recent activity. Reopen if you still need assistance.

stale[bot] avatar Nov 11 '25 04:11 stale[bot]