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

not working about validation

Open hans000 opened this issue 1 year ago • 4 comments

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

Expected Behavior

Steps To Reproduce

  1. click submit button
  2. change input(neither click set button or type text can not cancel the error message)

https://codesandbox.io/p/devbox/rjsf-validate-gwrxj2

Environment

- OS:
- Node:
- npm:

Anything else?

No response

hans000 avatar Apr 08 '24 01:04 hans000

Sorry, it's difficult to understand what your issue is. By default, validation only runs onSubmit. Is your issue resolved if you enable the liveValidate prop on Form, which triggers validation on change? liveValidate docs

nickgros avatar Apr 12 '24 19:04 nickgros

the liveValidate config is useful, but the initialization of the form to trigger the validation. UX is not very good.

hans000 avatar Apr 13 '24 03:04 hans000

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

Expected Behavior

Steps To Reproduce

  1. click submit button
  2. change input(neither click set button or type text can not cancel the error message)

https://codesandbox.io/p/devbox/rjsf-validate-gwrxj2

Environment

- OS:
- Node:
- npm:

Anything else?

No response

What I mean is that when there is a required form item, trigger the submit firstlly, and then after changing the value of the form item, the validation message can not be cancel.

hans000 avatar Apr 13 '24 03:04 hans000

@hans000 Are you trying to make the error go away once the user fixes it? If you don't want the error list to be shown, you could just hide it using the showErrorList prop on Form. If you do want it shown on submit, you could turn it off in a custom onChange() handler and then onSubmit() turn that flag back on. Honestly, I never show error list and just let each field have it errors shown when they happen since they go away once the error is fixed.

heath-freenome avatar Jul 05 '24 19:07 heath-freenome