{
  "type": "object",
  "properties": {
    "format": {
      "const": "standard-contract"
    },
    "formatVersion": {
      "const": "1.0"
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9.-]*$"
    },
    "version": {
      "type": "string",
      "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "appliesTo": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9.-]*$"
      }
    },
    "requirements": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9.-]*$"
          },
          "level": {
            "enum": [
              "must",
              "should",
              "may"
            ]
          },
          "text": {
            "type": "string",
            "minLength": 1
          },
          "verification": {
            "enum": [
              "manual",
              "equals"
            ]
          },
          "property": {
            "type": "string",
            "minLength": 1
          },
          "value": {},
          "guidance": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "id",
          "level",
          "text",
          "verification"
        ],
        "additionalProperties": false,
        "allOf": [
          {
            "if": {
              "properties": {
                "verification": {
                  "const": "equals"
                }
              }
            },
            "then": {
              "required": [
                "property",
                "value"
              ],
              "properties": {
                "level": {
                  "const": "must"
                }
              }
            },
            "else": {
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "property"
                    ]
                  },
                  {
                    "required": [
                      "value"
                    ]
                  }
                ]
              }
            }
          }
        ]
      }
    },
    "extends": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9.-]*$"
          },
          "version": {
            "type": "string",
            "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
          },
          "path": {
            "type": "string",
            "minLength": 1
          },
          "url": {
            "type": "string",
            "pattern": "^https?://[^\\s]+$"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "description": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "id",
          "version",
          "path",
          "sha256"
        ],
        "additionalProperties": false,
        "dependentRequired": {
          "path": [
            "sha256"
          ],
          "sha256": [
            "path"
          ]
        }
      }
    },
    "uses": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9.-]*$"
          },
          "version": {
            "type": "string",
            "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
          },
          "path": {
            "type": "string",
            "minLength": 1
          },
          "url": {
            "type": "string",
            "pattern": "^https?://[^\\s]+$"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "description": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "id",
          "version",
          "description"
        ],
        "additionalProperties": false,
        "dependentRequired": {
          "path": [
            "sha256"
          ],
          "sha256": [
            "path"
          ]
        }
      }
    },
    "extensions": {
      "type": "object"
    },
    "references": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9.-]*$"
          },
          "version": {
            "type": "string",
            "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
          },
          "path": {
            "type": "string",
            "minLength": 1
          },
          "url": {
            "type": "string",
            "pattern": "^https?://[^\\s]+$"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "description": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "id",
          "version"
        ],
        "additionalProperties": false,
        "dependentRequired": {
          "path": [
            "sha256"
          ],
          "sha256": [
            "path"
          ]
        }
      }
    },
    "specification": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9.-]*$"
        },
        "version": {
          "type": "string",
          "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
        },
        "path": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "pattern": "^https?://[^\\s]+$"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "description": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "id",
        "version"
      ],
      "additionalProperties": false,
      "dependentRequired": {
        "path": [
          "sha256"
        ],
        "sha256": [
          "path"
        ]
      }
    }
  },
  "required": [
    "format",
    "formatVersion",
    "id",
    "version",
    "title",
    "appliesTo",
    "requirements"
  ],
  "additionalProperties": false,
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
