Skip to content

Add tests for 'unevaluatedX' on invalid types #550

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

Merged
merged 2 commits into from
May 18, 2022

Conversation

EpicWink
Copy link
Contributor

Add tests for unevaluatedItems and unevaluatedProperties on non-applicable types (eg scalars)

@Julian
Copy link
Member

Julian commented May 18, 2022

The spec isn't as clear on these as it normally is it seems :/ but what part makes you say these are invalid? They seem like they should all be valid to me, and that like most other properties unevaluated* skips any non-relevant types.

@EpicWink
Copy link
Contributor Author

EpicWink commented May 18, 2022

what part makes you say these are invalid?

I hadn't really given it much thought. I was mostly dealing with the Python library which was raising an exception on unexpected input, regardless of the validity against the schema. I'll update the tests to mark them as expected to pass instead, because I agree with the relevance argument

@Julian
Copy link
Member

Julian commented May 18, 2022

It looks like we (the spec) no longer has specific sentences in each validator saying "the properties validator MUST consider valid any instance which is not an object" (or never did? Maybe I'm misremembering?).

Instead it says once, in 7.6.1:

Most assertions only constrain values within a certain primitive type. When the type of the instance is not of the type targeted by the keyword, the instance is considered to conform to the assertion.

So yeah it would seem that indeed these are all valid (as they are for other properties).

I may be missing it but it seems like it could be slightly easier to know when and how to apply 7.6.1 to each validator if the intended type was called out more explicitly. As-is it seems there's theoretically room for argument as to whether that section is intended for any given specific validator. CC @Relequestual to see if he has thoughts, though if I'm honest I only skimmed the spec and could be missing something.

Regardless, for the purposes of this suite, this is good now, thanks.

@Julian Julian merged commit 528fb62 into json-schema-org:master May 18, 2022
Julian added a commit that referenced this pull request May 18, 2022
Also make them match existing ones slightly more.
@karenetheridge
Copy link
Member

These tests should be added to draft2019-09 and draft-next as well.

@Julian
Copy link
Member

Julian commented May 18, 2022

That was done (in the linked commit) :)

@EpicWink EpicWink deleted the unevaluated-on-invalid branch May 18, 2022 22:05
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

Successfully merging this pull request may close these issues.

3 participants