JSON-Schema-Test-Suite icon indicating copy to clipboard operation
JSON-Schema-Test-Suite copied to clipboard

Add if/then/else test cases for issue #767

Open Shristibot opened this issue 1 month ago • 1 comments

This PR adds additional tests for correct handling of the false schema within conditional keywords (if, then, else), as described in Issue #767.

What these tests cover

  • When if matches, then: false must cause validation to fail.
  • When if does not match, else: false must cause validation to fail.
  • When both then and else are false, all data must be invalid regardless of the branch taken.
  • Ensures that false is treated as a schema that always fails, matching JSON Schema semantics, rather than being interpreted as {}.

These tests fill gaps in draft2020-12 conditional logic coverage, addressing the behavior described in Issue #767.

Fixes #767.

Shristibot avatar Dec 12 '25 20:12 Shristibot

@Zash, do these tests cover the case you were talking about in #767? It's not 100% clear to me what the case was exactly, especially because the example given was for not and these tests cover then/else.

jdesrosiers avatar Dec 16 '25 21:12 jdesrosiers

I think just the third test is sufficient. Or, just the first two. But, the first two and the third seem to be testing the same thing.

Thanks for the feedback — that makes sense.

I see how the third test is logically implied by the first two and doesn’t introduce a new failure mode. I’ll remove that case and update the tests accordingly.

I’ll push an update shortly.

Shristibot avatar Dec 25 '25 08:12 Shristibot

@Zash, do these tests cover the case you were talking about in #767? It's not 100% clear to me what the case was exactly, especially because the example given was for not and these tests cover then/else.

Thanks for raising that.

I didn’t add new tests for not because handling of false with not is already covered in the existing not.json tests, which assert that false is treated as a schema that always fails (rather than {}).

This PR was scoped specifically to fill the gap for conditional keywords (if / then / else), where equivalent coverage didn’t previously exist.

If you’d prefer additional or cross-referenced coverage for not in this context, I’m happy to add it.

Shristibot avatar Dec 25 '25 08:12 Shristibot

All checks are passing now. I’ve removed the redundant test case from all three files.

Please let me know if anything else needs adjustment.

Shristibot avatar Dec 25 '25 09:12 Shristibot