{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Edikka template profile 1.0",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "id",
    "version",
    "language",
    "marker",
    "rules"
  ],
  "properties": {
    "schemaVersion": {
      "const": "1.0"
    },
    "id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 400
    },
    "version": {
      "type": "string",
      "minLength": 1,
      "maxLength": 400
    },
    "language": {
      "type": "string",
      "minLength": 1,
      "maxLength": 400
    },
    "timezone": {
      "type": "string",
      "minLength": 1,
      "maxLength": 400
    },
    "referenceDate": {
      "type": "string",
      "minLength": 1,
      "maxLength": 400
    },
    "marker": {
      "type": "string",
      "minLength": 1,
      "maxLength": 400
    },
    "pageUrl": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "selector",
        "attribute"
      ],
      "properties": {
        "selector": {
          "type": "string",
          "minLength": 1,
          "maxLength": 400
        },
        "attribute": {
          "type": "string",
          "minLength": 1,
          "maxLength": 400
        }
      }
    },
    "rules": {
      "type": "array",
      "minItems": 1,
      "maxItems": 30,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "label",
          "reader",
          "expected",
          "scope",
          "selector",
          "source",
          "cardinality",
          "entity",
          "property",
          "absence",
          "ambiguity",
          "policy"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9._-]{0,79}$"
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 400
          },
          "reader": {
            "enum": [
              "date",
              "authors",
              "breadcrumb",
              "faq"
            ]
          },
          "expected": {
            "type": "boolean"
          },
          "scope": {
            "type": "string",
            "minLength": 1,
            "maxLength": 400
          },
          "selector": {
            "type": "string",
            "minLength": 1,
            "maxLength": 400
          },
          "source": {
            "enum": [
              "text",
              "attribute"
            ]
          },
          "attribute": {
            "type": "string",
            "minLength": 1,
            "maxLength": 400
          },
          "cardinality": {
            "enum": [
              "one",
              "set",
              "sequence"
            ]
          },
          "entity": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "types",
              "by"
            ],
            "properties": {
              "types": {
                "type": "array",
                "minItems": 1,
                "maxItems": 5,
                "uniqueItems": true,
                "items": {
                  "enum": [
                    "Article",
                    "BlogPosting",
                    "NewsArticle",
                    "FAQPage",
                    "BreadcrumbList"
                  ]
                }
              },
              "by": {
                "enum": [
                  "page_url",
                  "id",
                  "unique"
                ]
              },
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 400
              }
            },
            "allOf": [
              {
                "if": {
                  "properties": {
                    "by": {
                      "const": "id"
                    }
                  }
                },
                "then": {
                  "required": [
                    "id"
                  ]
                }
              }
            ]
          },
          "property": {
            "type": "string",
            "minLength": 1,
            "maxLength": 400
          },
          "absence": {
            "enum": [
              "undetermined",
              "not_applicable"
            ]
          },
          "absenceReason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 400
          },
          "ambiguity": {
            "const": "undetermined"
          },
          "policy": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "text",
              "urls"
            ],
            "properties": {
              "text": {
                "const": "space-presentation"
              },
              "urls": {
                "const": "conservative"
              },
              "dateFormat": {
                "enum": [
                  "iso",
                  "fr"
                ]
              },
              "order": {
                "enum": [
                  "set",
                  "sequence"
                ]
              },
              "lastUnlinked": {
                "enum": [
                  "both_absent",
                  "page_url"
                ]
              },
              "faqKey": {
                "enum": [
                  "question",
                  "identifier"
                ]
              },
              "links": {
                "type": "boolean"
              }
            }
          },
          "fields": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 400
              },
              "url": {
                "type": "string",
                "minLength": 1,
                "maxLength": 400
              },
              "question": {
                "type": "string",
                "minLength": 1,
                "maxLength": 400
              },
              "answer": {
                "type": "string",
                "minLength": 1,
                "maxLength": 400
              },
              "keyAttribute": {
                "type": "string",
                "minLength": 1,
                "maxLength": 400
              }
            }
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "source": {
                  "const": "attribute"
                }
              }
            },
            "then": {
              "required": [
                "attribute"
              ]
            }
          },
          {
            "if": {
              "properties": {
                "absence": {
                  "const": "not_applicable"
                }
              }
            },
            "then": {
              "required": [
                "absenceReason"
              ],
              "properties": {
                "expected": {
                  "const": false
                }
              }
            }
          }
        ]
      }
    }
  }
}
