Skip to content

Mutual Dependency lesson is missing a test case #167

Open
@AhmedHanyGamal

Description

@AhmedHanyGamal

The lesson on Ensuring Mutual Dependency does not include a test case that clearly shows the difference between mutual dependency and just using the required keyword.

The main difference is that with mutual dependency, a JSON document is still valid if it does not include either of the two related properties. But if instead required is used on the two properties, the document would be invalid.

As a result, the following schema passes the lesson, even though it shouldn't:

{
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "creditCardNumber": {
      "type": "string"
    },
    "address": {
      "type": "string"
    }
  },
  "required": [
    "name",
    "creditCardNumber",
    "address"
  ]
}

The following test case should fix this issue

{
  "name": "John Doe"
}

This should be valid with mutual dependency but would fail if required was used.


I would like to be assigned to this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions