Skip to content

Conversation

@eitamal
Copy link
Contributor

@eitamal eitamal commented Sep 12, 2025

What kind of change does this PR introduce?

This PR adds the required validation on the properties that have an if applicator condition applied to them in the example schemas in the instructions for the following lessons:

Issue Number:

Summary

By adding the required validation in the instructions, it should help clarify that by nature of the if applicator being a subschema, the same rules apply. That is, if the property that the if relies on doesn't exist on the instance, and there's nothing making sure it exists (e.g. required), the condition would still apply - which could be confusing to someone whose still learning how it works.

Does this PR introduce a breaking change?

No - only documentation was changed.

Note

Once I started working on this, I realized I may have overestimated the reach of the problem in the issue I've opened initially (#180) - applying only to the instructions and not to the solutions as well and only to lessons 4 and 6 (not 5).

I wanted to thank the maintainers, too! The tour helped me get a better grasp of JSON schema.

Closes json-schema-org#180

This commit adds the `required` validation on the properties that have
an `if` applicator condition applied to them in the *instructions* for
the following lessons:

-
[05-Conditional-Validation/04-if-then-keyword](https://tour.json-schema.org/content/05-Conditional-Validation/04-if-then-keyword)
-
[https://tour.json-schema.org/content/05-Conditional-Validation/06-Expanding-If-then-else](https://tour.json-schema.org/content/05-Conditional-Validation/06-Expanding-If-then-else)
Comment on lines 49 to 50
},
"required": ["status"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go in the if schema.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Sorry about that.

This commit moves the `required` validation for the example schema in
ch05's lesson "Expanding If-then-else" and places it in the `if`
subschema, so that it applies only for the purpose of the condition.
@JeelRajodiya
Copy link
Member

@jdesrosiers I'll merge the PR once you approve!

Copy link
Member

@jdesrosiers jdesrosiers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for making this fix!

@JeelRajodiya JeelRajodiya merged commit 3a6dc23 into json-schema-org:main Sep 17, 2025
1 check passed
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.

if-then-* series of lessons' examples are missing a required validation

3 participants