{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openjuvenile.org/schemas/v0.2/compliance.schema.json",
  "title": "Compliance block",
  "description": "Regulatory information for the markets a product is sold in: applied regulations, standards with version, test reports, warnings per language, safety information and the link to the Digital Product Passport. Manufacturer and EU responsible person are part of the core. Conforming data does not mean that the product complies with the law.",
  "$comment": "Draft 0.2 covers the EU. Compliance blocks for further markets (UK, USA, China) are planned.",
  "type": "object",
  "properties": {
    "markets": {
      "description": "Markets the product is placed on: ISO 3166-1 alpha-2 country codes, or EU for the whole European Union.",
      "type": "array",
      "items": {
        "description": "Country code or EU.",
        "type": "string",
        "pattern": "^([A-Z]{2}|EU)$",
        "examples": ["EU"]
      },
      "minItems": 1,
      "uniqueItems": true
    },
    "regulations": {
      "description": "Regulations the product is placed on the market under.",
      "type": "array",
      "items": {
        "description": "One regulation.",
        "type": "object",
        "properties": {
          "id": {
            "description": "Identifier of the regulation: jurisdiction, year and number, for example EU-2023/988. Approvals of child car seats (UN R129, UN R44) are recorded in the car seat profile, not here.",
            "type": "string",
            "minLength": 1,
            "examples": ["EU-2023/988"]
          },
          "name": {
            "description": "Name of the regulation.",
            "type": "string",
            "minLength": 1,
            "examples": ["General Product Safety Regulation"]
          }
        },
        "required": ["id", "name"],
        "additionalProperties": false
      },
      "minItems": 1
    },
    "standards": {
      "description": "Standards the product was designed and tested to, with version.",
      "type": "array",
      "items": {
        "description": "One applied standard.",
        "type": "object",
        "properties": {
          "code": {
            "description": "Designation of the standard including its part number, as printed on the standard.",
            "type": "string",
            "minLength": 1,
            "examples": ["EN 1888-2"]
          },
          "version": {
            "description": "Edition of the standard, usually the year of publication including amendments.",
            "type": "string",
            "minLength": 1,
            "x-openjuvenile-level": "should",
            "examples": ["2018"]
          },
          "part": {
            "description": "Part of the product the standard applies to, if it does not apply to the whole product (for example carrycot).",
            "$comment": "TODO(review): confirm the intended meaning of `part` (product part vs. part number of the standard).",
            "type": "string",
            "minLength": 1,
            "x-openjuvenile-level": "may",
            "examples": ["carrycot"]
          }
        },
        "required": ["code"],
        "additionalProperties": false
      },
      "x-openjuvenile-level": "should"
    },
    "testReports": {
      "description": "Test reports that document the conformity assessment.",
      "type": "array",
      "items": {
        "description": "One test report.",
        "type": "object",
        "properties": {
          "standardCode": {
            "description": "Standard the test was carried out against; matches standards[].code.",
            "type": "string",
            "minLength": 1,
            "examples": ["EN 1888-2"]
          },
          "laboratory": {
            "description": "Name of the testing laboratory.",
            "type": "string",
            "minLength": 1,
            "examples": ["Example Test Laboratory"]
          },
          "reportNumber": {
            "description": "Number of the test report.",
            "type": "string",
            "minLength": 1,
            "examples": ["EX-0001-2026"]
          },
          "issueDate": {
            "$ref": "core.schema.json#/$defs/date",
            "description": "Date the report was issued.",
            "x-openjuvenile-level": "should"
          },
          "documentUrl": {
            "$ref": "core.schema.json#/$defs/url",
            "description": "Link to the report, if it is shared.",
            "x-openjuvenile-level": "may"
          }
        },
        "required": ["standardCode", "laboratory", "reportNumber"],
        "additionalProperties": false
      },
      "x-openjuvenile-level": "should"
    },
    "ceMarking": {
      "description": "Whether the product carries the CE marking.",
      "type": "boolean",
      "x-openjuvenile-level": "should",
      "examples": [false]
    },
    "warnings": {
      "description": "Warnings that come with the product, each with its text per language. Online offers have to show the required warnings and safety information.",
      "type": "array",
      "items": {
        "description": "One warning.",
        "type": "object",
        "properties": {
          "type": {
            "description": "Kind of warning: safety, usage, age, choking or other.",
            "type": "string",
            "enum": ["safety", "usage", "age", "choking", "other"],
            "examples": ["safety"]
          },
          "text": {
            "$ref": "core.schema.json#/$defs/localizedString",
            "description": "Wording of the warning as on the product or in the instructions, per language."
          }
        },
        "required": ["type", "text"],
        "additionalProperties": false
      },
      "minItems": 1,
      "x-openjuvenile-level": "conditional",
      "x-openjuvenile-condition": "The product comes with warnings (on the product, the packaging or in the instructions)."
    },
    "safetyInformation": {
      "$ref": "core.schema.json#/$defs/localizedString",
      "description": "Further safety information for consumers, per language.",
      "x-openjuvenile-level": "may"
    },
    "digitalProductPassport": {
      "description": "Access to the Digital Product Passport (DPP) of the product.",
      "type": "object",
      "properties": {
        "dataCarrierUrl": {
          "$ref": "core.schema.json#/$defs/url",
          "description": "URL encoded in the data carrier (for example a QR code) that leads to the passport.",
          "x-openjuvenile-level": "should"
        },
        "gs1DigitalLink": {
          "$ref": "core.schema.json#/$defs/url",
          "description": "GS1 Digital Link URI of the product.",
          "x-openjuvenile-level": "may",
          "examples": ["https://id.example.com/01/09521234567899"]
        },
        "registryId": {
          "description": "Identifier of the passport in the EU DPP registry, once registered.",
          "type": "string",
          "minLength": 1,
          "x-openjuvenile-level": "may"
        }
      },
      "minProperties": 1,
      "additionalProperties": false,
      "x-openjuvenile-level": "may"
    },
    "substances": {
      "description": "Information on substances of very high concern (SVHC).",
      "type": "object",
      "properties": {
        "svhcPresent": {
          "description": "Whether the product contains substances of very high concern (SVHC).",
          "type": "boolean",
          "examples": [false]
        },
        "svhcList": {
          "description": "Substances of very high concern contained in the product.",
          "type": "array",
          "items": {
            "description": "One substance.",
            "type": "object",
            "properties": {
              "name": {
                "description": "Name of the substance.",
                "type": "string",
                "minLength": 1
              },
              "casNumber": {
                "description": "CAS registry number of the substance.",
                "type": "string",
                "pattern": "^\\d{2,7}-\\d{2}-\\d$",
                "x-openjuvenile-level": "should"
              }
            },
            "required": ["name"],
            "additionalProperties": false
          },
          "x-openjuvenile-level": "conditional",
          "x-openjuvenile-condition": "svhcPresent is true."
        },
        "scipNumber": {
          "description": "SCIP notification number.",
          "type": "string",
          "minLength": 1,
          "x-openjuvenile-level": "may"
        }
      },
      "required": ["svhcPresent"],
      "additionalProperties": false,
      "x-openjuvenile-level": "may",
      "if": {
        "properties": {
          "svhcPresent": {
            "const": true
          }
        },
        "required": ["svhcPresent"]
      },
      "then": {
        "required": ["svhcList"]
      }
    },
    "connectedProduct": {
      "description": "Information for products with radio or internet functions, such as baby monitors.",
      "type": "object",
      "properties": {
        "hasRadio": {
          "description": "Whether the product contains a radio module.",
          "type": "boolean"
        },
        "hasInternetConnection": {
          "description": "Whether the product can connect to the internet.",
          "type": "boolean"
        },
        "cybersecurityNotes": {
          "$ref": "core.schema.json#/$defs/localizedString",
          "description": "Notes on security updates and data handling, per language.",
          "x-openjuvenile-level": "may"
        }
      },
      "required": ["hasRadio", "hasInternetConnection"],
      "additionalProperties": false,
      "x-openjuvenile-level": "may"
    }
  },
  "required": ["markets", "regulations"],
  "patternProperties": {
    "^x-": {
      "description": "Extension fields. Names start with x- and are ignored by consumers that do not know them."
    }
  },
  "additionalProperties": false
}
