Skip to content
Discussion options

You must be logged in to vote

Hey @andlbrei ,

The problem is on your if. Your check there is essentially saying that "if (if otherIncomeSource is defined and matches the given schema...)", but doesn't enforce otherIncomeSource to be present. Hence, an empty schema passes the if and you get into then, which forces otherIncomeSourceOtherComment to be required. Instead, you probably want to add required to your if as well, so that the empty instance doesn't pass:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "otherIncomeSource": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "otherIncomeSourceOtherComment": {
      "type": "s…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@andlbrei
Comment options

Answer selected by andlbrei
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants