Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ajv8 does not properly show errors inline under certain circumstances when ajv6 does #3260

Closed
1 task done
cdolek opened this issue Nov 28, 2022 · 6 comments · Fixed by #3309
Closed
1 task done

ajv8 does not properly show errors inline under certain circumstances when ajv6 does #3260

cdolek opened this issue Nov 28, 2022 · 6 comments · Fixed by #3309
Assignees

Comments

@cdolek
Copy link

cdolek commented Nov 28, 2022

Prerequisites

What theme are you using?

core

What is your question?

With ajv6 the form errors (e.g. required properties) were displayed right under the form elements, which is very helpful especially when you use live validation.

While ajv8 validation marks form elements as invalid, error messages show up below the whole form. The longer the form, the higher chance of error messages being displayed outside users' view === bad user experience.

I would like the error messages to be shown right below the form elements. Is there a way to achieve this?

What I noticed is that rawErrors is not being passed to the individual form element using v8.

Help appreciated.

@cdolek cdolek added needs triage Initial label given, to be assigned correct labels and assigned question labels Nov 28, 2022
@cdolek cdolek changed the title User Experience related ajv6 vs ajv8 question User Experience related ajv6 vs ajv8 question (all themes are effected by this) Nov 28, 2022
@cdolek cdolek changed the title User Experience related ajv6 vs ajv8 question (all themes are effected by this) Deprecated ajv6 vs ajv8 question (all themes are effected by this) <User Experience Issue> Nov 30, 2022
@heath-freenome heath-freenome removed the needs triage Initial label given, to be assigned correct labels and assigned label Dec 2, 2022
@cdolek
Copy link
Author

cdolek commented Dec 6, 2022

@heath-freenome any insights on this? Thank you

@heath-freenome
Copy link
Member

heath-freenome commented Dec 6, 2022

Hmmm, this may be a bug related to subtle differences between ajv6 and ajv8 and how we are using them. Do you have a reproducible test case?

@cdolek
Copy link
Author

cdolek commented Dec 8, 2022

@heath-freenome
Copy link
Member

Here it is inside of the playground

@heath-freenome heath-freenome self-assigned this Dec 9, 2022
@heath-freenome heath-freenome changed the title Deprecated ajv6 vs ajv8 question (all themes are effected by this) <User Experience Issue> ajv8 does not properly show errors inline under certain circumstances when ajv6 does Dec 9, 2022
@nickgros
Copy link
Contributor

nickgros commented Dec 9, 2022

It looks like the Ajv raw errors for missing required properties doesn't point to the property, but to the object containing the required property in the schema. We may have to manually create the path in an error transform.

@heath-freenome
Copy link
Member

It looks like the Ajv raw errors for missing required properties doesn't point to the property, but to the object containing the required property in the schema. We may have to manually create the path in an error transform.

Hopefully this is a fix in transformRJSFValidationErrors() in validator-ajv8 validator.ts

heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Dec 22, 2022
fix rjsf-team#3260

The required field errors weren't mapped to the fields they were associated to in the `ErrorSchema`
This mapping issue was fixed as follows:
- In `@rjsf/core`, updated the `Form` and `validate` tests to fix the mapping issue in the test data for the required fields
- In `@rjsf/validator-ajv6`, added additional tests for testing top-level and nested required field errors to verify things worked with ajv6
- In `@rjsf/validator-ajv8`, fixed the `transformRJSFValidationErrors()` function in the validator to look for `missingProperty: 'field'` information in the `params` property using that to properly map the error `property`
  - Replicated the tests made in `@rjsf/validator-ajv6` to this package to verify that the fix is working properly
- Updated the `CHANGELOG.md` accordingly
heath-freenome added a commit that referenced this issue Dec 22, 2022
fix #3260

The required field errors weren't mapped to the fields they were associated to in the `ErrorSchema`
This mapping issue was fixed as follows:
- In `@rjsf/core`, updated the `Form` and `validate` tests to fix the mapping issue in the test data for the required fields
- In `@rjsf/validator-ajv6`, added additional tests for testing top-level and nested required field errors to verify things worked with ajv6
- In `@rjsf/validator-ajv8`, fixed the `transformRJSFValidationErrors()` function in the validator to look for `missingProperty: 'field'` information in the `params` property using that to properly map the error `property`
  - Replicated the tests made in `@rjsf/validator-ajv6` to this package to verify that the fix is working properly
- Updated the `CHANGELOG.md` accordingly
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this issue Jun 8, 2023
fix rjsf-team#3260

The required field errors weren't mapped to the fields they were associated to in the `ErrorSchema`
This mapping issue was fixed as follows:
- In `@rjsf/core`, updated the `Form` and `validate` tests to fix the mapping issue in the test data for the required fields
- In `@rjsf/validator-ajv6`, added additional tests for testing top-level and nested required field errors to verify things worked with ajv6
- In `@rjsf/validator-ajv8`, fixed the `transformRJSFValidationErrors()` function in the validator to look for `missingProperty: 'field'` information in the `params` property using that to properly map the error `property`
  - Replicated the tests made in `@rjsf/validator-ajv6` to this package to verify that the fix is working properly
- Updated the `CHANGELOG.md` accordingly
shijistar pushed a commit to shijistar/react-jsonschema-form that referenced this issue Jun 8, 2023
fix rjsf-team#3260

The required field errors weren't mapped to the fields they were associated to in the `ErrorSchema`
This mapping issue was fixed as follows:
- In `@rjsf/core`, updated the `Form` and `validate` tests to fix the mapping issue in the test data for the required fields
- In `@rjsf/validator-ajv6`, added additional tests for testing top-level and nested required field errors to verify things worked with ajv6
- In `@rjsf/validator-ajv8`, fixed the `transformRJSFValidationErrors()` function in the validator to look for `missingProperty: 'field'` information in the `params` property using that to properly map the error `property`
  - Replicated the tests made in `@rjsf/validator-ajv6` to this package to verify that the fix is working properly
- Updated the `CHANGELOG.md` accordingly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants