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

compileSchemaValidator doesn't resolve condition schemas if used in an array #3689

Closed
4 tasks done
cwendtxealth opened this issue May 23, 2023 · 1 comment · Fixed by #3690
Closed
4 tasks done

compileSchemaValidator doesn't resolve condition schemas if used in an array #3689

cwendtxealth opened this issue May 23, 2023 · 1 comment · Fixed by #3690
Labels

Comments

@cwendtxealth
Copy link
Contributor

Prerequisites

What theme are you using?

core

Version

5.7.2

Current Behavior

When pre compiling a schema that has a condition statement in an array items field, the schemaParser function in utils does not resolve the condition schema. The compiled schema should export the condition schema in its own validate function. Here is a codesandbox.io example using a pre compiled schema with a simple array field using conditions. Schema looks like this

{
  type: "object",
  properties: {
    list: {
      type: "array",
      items: {
        type: "object",
        properties: {
          country: {
            default: "United States of America",
            enum: ["United States of America", "Canada"]
          }
        },
        if: {
          properties: { country: { const: "United States of America" } }
        },
        then: {
          properties: { postal_code: { pattern: "[0-9]{5}(-[0-9]{4})?" } }
        },
        else: {
          properties: {
            postal_code: { pattern: "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]" }
          }
        }
      }
    }
  }
}

Expected Behavior

Expected the form component to load with correct fields. In the codesandbox.io example you can see the expected behavior from ExpectedApp component.

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 May 23, 2023
@cwendtxealth
Copy link
Contributor Author

creating a pr now that fixes this issue

@heath-freenome heath-freenome removed the needs triage Initial label given, to be assigned correct labels and assigned label May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants