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

ensure on array does not work/missing example #154

Open
ZipBrandon opened this issue Jul 17, 2023 · 2 comments
Open

ensure on array does not work/missing example #154

ZipBrandon opened this issue Jul 17, 2023 · 2 comments

Comments

@ZipBrandon
Copy link

I have tried multiple ways but cannot get this to work. When a single item is selected against my schema it does not validate and complains about making it nullable. When I have 2+ items then it works successfully. I can get this to work using building the Yup schema natively but cannot figure out how to get it work the JSON Schema.

@kristianmandrup
Copy link
Owner

There are still a few limitations with this library. I was counting on the community to chip in with extensions. Why I've tried to make this library easy to extend and customize. I'd like to see your concrete test case, then we can work from there.

@ZipBrandon
Copy link
Author

Sure. I referenced https://github.com/kristianmandrup/schema-to-yup#array and put ensure like this for my array of strings. I also was wondering if ensureItems was a valid value and tried that with no luck.

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "surveys": {
      "type": "object",
      "properties": {
        "c632143a-63e5-475e-a866-2b13868f9974": {
          "type": "object",
          "properties": {
            "3799f3c3-9d4c-4fa1-aac0-24c0d211dd49": {
              "type": "array",
              "errMessages": {},
              "ensure": true,
              "items": {
                "type": "string"
              }
            },
            "c219ae03-f973-4176-9b1b-77811d0793a2": {
              "type": "array",
              "errMessages": {},
              "ensure": true,
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants