fix: add required validation to if lesssons (#180) - #181
Merged
Conversation
Closes #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)
jdesrosiers
reviewed
Sep 12, 2025
Comment on lines
+49
to
+50
| }, | ||
| "required": ["status"] |
Member
There was a problem hiding this comment.
This should go in the if schema.
Contributor
Author
There was a problem hiding this comment.
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.
Member
|
@jdesrosiers I'll merge the PR once you approve! |
jdesrosiers
approved these changes
Sep 15, 2025
jdesrosiers
left a comment
Member
There was a problem hiding this comment.
Looks good. Thanks for making this fix!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
This PR adds the
requiredvalidation on the properties that have anifapplicator condition applied to them in the example schemas in the instructions for the following lessons:Issue Number:
if-then-*series of lessons' examples are missing arequiredvalidation #180Summary
By adding the
requiredvalidation in the instructions, it should help clarify that by nature of theifapplicator being a subschema, the same rules apply. That is, if the property that theifrelies 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.