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

Precompiled Validator errors schema differs when they are the same #3825

Closed
3 of 4 tasks
cwendtxealth opened this issue Aug 13, 2023 · 1 comment · Fixed by #3826
Closed
3 of 4 tasks

Precompiled Validator errors schema differs when they are the same #3825

cwendtxealth opened this issue Aug 13, 2023 · 1 comment · Fixed by #3826
Labels
bug needs triage Initial label given, to be assigned correct labels and assigned

Comments

@cwendtxealth
Copy link
Contributor

Prerequisites

What theme are you using?

core

Version

5.12

Current Behavior

In precompiledValidator class it sets the root schema in the constructor that is then compared to the passed in schema in rawValidation. These two schemas could differ when being evaluated with formData when using conditional logic that adds required fields. Here is example of simple schema that would cause this error.

{
  type: 'object',
  properties: {
    test: {
      type: 'string'
    },
    error: {
      type: 'string'
    }
  },
  allOf: [{
    if: { 
      properties: {
        test: { const: 'error' }
      },
      required: ['test'] 
    },
    then: { required: ['error'] }
  }],
  required: ['test']
}

When test field is set to error it will make error field required changing the schema and then will not match the rootSchema. To fix this the rootSchema should be resolved at the time rawValidation is being evaluated with formData.

Expected Behavior

No response

Steps To Reproduce

No response

Environment

- OS:
- Node:
- npm:

Anything else?

No response

@cwendtxealth cwendtxealth added bug needs triage Initial label given, to be assigned correct labels and assigned labels Aug 13, 2023
@cwendtxealth
Copy link
Contributor Author

PR incoming to fix this

cwendtxealth added a commit to cwendtxealth/react-jsonschema-form that referenced this issue Aug 13, 2023
heath-freenome added a commit that referenced this issue Aug 15, 2023
* fix: Fixes #3825 Precompiled validator resolve root schema

* update changelog

---------

Co-authored-by: Heath C <51679588+heath-freenome@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs triage Initial label given, to be assigned correct labels and assigned
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant