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

Adding required field in nested if/then/else not working correctly #4138

Closed
4 tasks done
I-Smith opened this issue Mar 20, 2024 · 2 comments
Closed
4 tasks done

Adding required field in nested if/then/else not working correctly #4138

I-Smith opened this issue Mar 20, 2024 · 2 comments

Comments

@I-Smith
Copy link

I-Smith commented Mar 20, 2024

Prerequisites

What theme are you using?

core

Version

5.17.1

Current Behavior

Using the following JSON Schema

{
  "type": "object",
  "properties": {
    "testSection": {
      "type": "object",
      "properties": {
        "testBool": {
          "type": "boolean"
        },
        "testString": {
          "type": "string"
        }
      },
      "required": [
        "testBool"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "testBool": {
                "const": "true"
              }
            }
          },
          "then": {
            "required": [
              "testString"
            ]
          }
        }
      ]
    }
  }
}

The the required array inside testSection is not being updated to include testBool as I would expect it to.
Unless I'm missing something glaringly obvious, but I've been playing with this awhile and haven't been able to get this working.

Expected Behavior

Retrieved schema should reflect values outlined in nested if/then/else blocks.

Steps To Reproduce

Playground link

Changing the boolean value does not cause the text field to be required

Environment

- OS: macOS Sonoma 14.4
- Node: 18.19.1
- npm: 10.2.4

Anything else?

No response

@I-Smith I-Smith added bug needs triage Initial label given, to be assigned correct labels and assigned labels Mar 20, 2024
@nickgros nickgros added question and removed bug needs triage Initial label given, to be assigned correct labels and assigned labels Mar 22, 2024
@nickgros
Copy link
Contributor

@I-Smith not a bug, your "const" property in the "if" is the string "true". I think you expect it to be the boolean true:

Playground link

@I-Smith
Copy link
Author

I-Smith commented Mar 25, 2024

Interesting. I have it correct in my actual project, so I suppose that's not the root issue. I'll try to find what's actually going on and open a new issue if needed, thanks.

@I-Smith I-Smith closed this as completed Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants