Skip to content

"unevaluatedItems" and "contains", "minContains", and "maxContains" #293

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

Closed
3 tasks
handrews opened this issue Oct 20, 2019 · 3 comments
Closed
3 tasks
Labels
missing test A request to add a test to the suite that is currently not covered elsewhere.
Milestone

Comments

@handrews
Copy link
Contributor

handrews commented Oct 20, 2019

This is a little vague in the spec, as discussed in json-schema-org/json-schema-spec#810, but will be clarified in a bug fix and we should go ahead and test for it from the start.

contains gets applied to all elements of the array, and excludes any element to which it applied successfully from unevaluatedItems. This produces an interesting and potentially useful behavior of carving out exceptions in an otherwise homogenous array, which you can't otherwise do.

Given:

{
  "type": "array",
  "oneOf": [
    {
      "contains": {"type": "string"}
    },
    {
      "items": {"type": "integer"}
    }
  ],
  "unevaluatedItems": {"type": "boolean"}
}

The following instances should all be valid:

  • [true, "hello", false]
  • [1, 3, 4]
  • [true, false]

Note that minContains and maxContains shouldn't affect this (although I don't think there's any meaningful interaction with maxContains as matching less is no different than if it's not there, and matching more causes it to fail validation):

  • if contains matches more than the minimum, all of those should be excluded from unevaluatedItems, not just the first however many up to the minimum
@handrews handrews added this to the 2019-09 milestone Oct 20, 2019
@Julian Julian added the missing test A request to add a test to the suite that is currently not covered elsewhere. label Nov 29, 2019
@ssilverman
Copy link
Member

ssilverman commented Apr 25, 2020

If [true, false] doesn't satisfy the oneOf, shouldn't it be considered invalid? (per json-schema-org/json-schema-spec#810 (comment))

@Julian
Copy link
Member

Julian commented Jul 6, 2022

@ssilverman is correct here (given the edit in the linked ticket), so removing that example ([true, false]), will see if we already have tests for the other two, I think we may.

@gregsdennis
Copy link
Member

No further tests are needed. Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
missing test A request to add a test to the suite that is currently not covered elsewhere.
Projects
None yet
Development

No branches or pull requests

4 participants