Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Fix common bug with if/then pattern #143

Merged
merged 1 commit into from
Mar 31, 2021
Merged

Fix common bug with if/then pattern #143

merged 1 commit into from
Mar 31, 2021

Conversation

jdesrosiers
Copy link
Member

It's a very common bug to leave out the required keyword when using if/then. I recently realized that this site has the same error and is likely one of the reasons we see that problem so frequently. In this PR, I've fixed the bug and included some "note" blocks to explain why required is an important part of using this pattern.

I also noticed that the truth table has multiple problems

  • Only half of the table renders. The first three rows get cut off.
  • It's confusing. I found it difficult to understand whether "X" represented true or false.
  • It's missing the T T T T case
  • The "whole schema" value is incorrect in multiple places
  • It doesn't take into account what happens if any of these keywords are not defined.

I we-wrote the truth table to take all of these things into account, but it ended up being rather large, so I condensed it into something that isn't quite a truth table, but is more clear. I did this by,

  • Defining that a missing then or else has a default value of true.
  • Using n/a to combine entries where a value had no effect on the result.

I used "T" and "F" to make the table a little more clear. Using an "X" and check mark (instead of empty space) would work as well, but I'm not familiar enough with the rst format to add special characters correctly.

@jdesrosiers jdesrosiers merged commit e76bf1c into json-schema-org:master Mar 31, 2021
@jdesrosiers jdesrosiers deleted the fix-conditionals branch March 31, 2021 18:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant