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

"additionalItems" should not be honored if "items" is an object. #135

Closed
SereneAnt opened this issue Nov 8, 2016 · 5 comments
Closed

"additionalItems" should not be honored if "items" is an object. #135

SereneAnt opened this issue Nov 8, 2016 · 5 comments

Comments

@SereneAnt
Copy link

As per json-schema specification:

if "items" is not present, or its value is an object, validation of the instance always succeeds, regardless of the value of "additionalItems";

Currently (v 4.0.x), CollectionConstraint makes an extra checks for "additionalItems" if "items" is object and fails validation.

@SereneAnt
Copy link
Author

Wrong repo.

@awwright
Copy link
Member

awwright commented Nov 8, 2016

@SereneAnt Just a heads up that language is a tad bit confusing, the language seems to only apply for "items", "additionalItems" should still be able to fail even if "items" isn't defined. If in doubt check the behavior against the official test suite. If it's all too confusing, please let us know.

@epoberezkin
Copy link
Member

@awwright:

"additionalItems" should still be able to fail even if "items" isn't defined

there is no test for such scenario in the test suite you are referring to. The draft says in clear terms that additionalItems are only taken into account when items is array.

@handrews
Copy link
Contributor

handrews commented Nov 21, 2016

The draft says in clear terms that additionalItems are only taken into account when items is array.

Also important is this line in "items":

If absent, it can be considered present with an empty schema.

This means that "items" is effectively always defined, so "additionalItems" cannot be applied unless "items" is an array of schemas. The default empty schema value of "items" takes precedence.

handrews added a commit to handrews/json-schema-spec that referenced this issue Nov 21, 2016
In json-schema-org#135 the question of whether additionalItems could fail validation
if items is not defined was raised.  Since items defines a default
value of {}, it is never undefined, which is clarified in this change.
@handrews
Copy link
Contributor

I'd say, array of schemas. If it is a schema, additionaltems is ignored.

Oops, that was a typo, I'll edit it.

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

4 participants