{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openjuvenile.org/schemas/v0.2/profiles/car-seat.schema.json",
  "title": "Category profile – car seats",
  "description": "Fields for child car seats (category code car-seat). Seats approved under UN R129 are described by the child's height; seats approved under UN R44 by weight groups.",
  "$comment": "TODO(review): the levels of the profile fields are a first proposal for the working group Strollers & car seats.",
  "type": "object",
  "properties": {
    "approvalRegulation": {
      "description": "Regulation the seat is approved under, as shown on the approval label.",
      "type": "string",
      "enum": ["UN R129", "UN R44"],
      "examples": ["UN R129"]
    },
    "approvalNumber": {
      "description": "Approval number as shown on the approval label of the seat.",
      "type": "string",
      "minLength": 1,
      "examples": ["E4 129R-03/0000"]
    },
    "iSize": {
      "description": "Whether the seat is approved in an i-Size category of UN R129.",
      "type": "boolean",
      "x-openjuvenile-level": "conditional",
      "x-openjuvenile-condition": "approvalRegulation is UN R129.",
      "examples": [true]
    },
    "childHeightCm": {
      "$ref": "../core.schema.json#/$defs/closedRange",
      "description": "Range of the child's height (stature) the seat is approved for, in cm.",
      "x-openjuvenile-level": "conditional",
      "x-openjuvenile-condition": "approvalRegulation is UN R129."
    },
    "childWeightKg": {
      "$ref": "../core.schema.json#/$defs/range",
      "description": "Range of the child's weight the seat is approved for, in kg.",
      "x-openjuvenile-level": "conditional",
      "x-openjuvenile-condition": "approvalRegulation is UN R44, or the UN R129 approval states a weight limit."
    },
    "weightGroups": {
      "description": "Weight groups of the UN R44 approval.",
      "type": "array",
      "items": {
        "description": "One weight group.",
        "type": "string",
        "enum": ["0", "0+", "I", "II", "III"],
        "examples": ["0+"]
      },
      "minItems": 1,
      "uniqueItems": true,
      "x-openjuvenile-level": "conditional",
      "x-openjuvenile-condition": "approvalRegulation is UN R44."
    },
    "orientation": {
      "description": "Direction of travel in which the seat can be installed.",
      "type": "string",
      "enum": ["rearward", "forward", "both"],
      "examples": ["rearward"]
    },
    "orientationRanges": {
      "description": "Limits per direction of travel, for seats that can be installed both ways.",
      "type": "array",
      "items": {
        "description": "Limits for one direction of travel.",
        "type": "object",
        "properties": {
          "direction": {
            "description": "Direction of travel.",
            "type": "string",
            "enum": ["rearward", "forward"],
            "examples": ["rearward"]
          },
          "childHeightCm": {
            "$ref": "../core.schema.json#/$defs/closedRange",
            "description": "Range of the child's height in this direction, in cm.",
            "x-openjuvenile-level": "conditional",
            "x-openjuvenile-condition": "approvalRegulation is UN R129."
          },
          "childWeightKg": {
            "$ref": "../core.schema.json#/$defs/range",
            "description": "Range of the child's weight in this direction, in kg.",
            "x-openjuvenile-level": "conditional",
            "x-openjuvenile-condition": "approvalRegulation is UN R44, or the approval states a weight limit for this direction."
          }
        },
        "required": ["direction"],
        "additionalProperties": false
      },
      "minItems": 2,
      "x-openjuvenile-level": "conditional",
      "x-openjuvenile-condition": "orientation is both."
    },
    "installation": {
      "description": "Ways the seat can be fixed in the vehicle: isofix (ISOFIX anchorages) or vehicle-belt (the vehicle's adult belt). Several values mean that each of them is possible.",
      "type": "array",
      "items": {
        "description": "One way of fixing the seat.",
        "type": "string",
        "enum": ["isofix", "vehicle-belt"],
        "examples": ["isofix"]
      },
      "minItems": 1,
      "uniqueItems": true
    },
    "baseRequired": {
      "description": "Whether the seat can only be installed on a separate base. Compatible bases are listed in the compatibility block.",
      "type": "boolean",
      "x-openjuvenile-level": "should",
      "examples": [false]
    },
    "restraint": {
      "description": "How the child is held in the seat: integral-harness (the seat's own harness) · impact-shield · vehicle-belt (the vehicle's adult belt, for example in booster seats).",
      "type": "string",
      "enum": ["integral-harness", "impact-shield", "vehicle-belt"],
      "x-openjuvenile-level": "should",
      "examples": ["integral-harness"]
    },
    "supportLeg": {
      "description": "Whether the seat or its base has a support leg.",
      "type": "boolean",
      "x-openjuvenile-level": "should",
      "examples": [true]
    },
    "topTether": {
      "description": "Whether the seat uses a top tether strap.",
      "type": "boolean",
      "x-openjuvenile-level": "should",
      "examples": [false]
    },
    "rotation": {
      "description": "Whether the seat shell rotates for getting the child in and out.",
      "type": "boolean",
      "x-openjuvenile-level": "may",
      "examples": [false]
    },
    "vehicleTypeApproval": {
      "description": "universal: fits vehicles with the corresponding seating positions · specific-vehicle: approved for the vehicles in a vehicle list.",
      "type": "string",
      "enum": ["universal", "specific-vehicle"],
      "x-openjuvenile-level": "should",
      "examples": ["universal"]
    },
    "vehicleListUrl": {
      "$ref": "../core.schema.json#/$defs/url",
      "description": "Link to the manufacturer's vehicle list.",
      "x-openjuvenile-level": "conditional",
      "x-openjuvenile-condition": "vehicleTypeApproval is specific-vehicle."
    }
  },
  "required": ["approvalRegulation", "approvalNumber", "orientation", "installation"],
  "patternProperties": {
    "^x-": {
      "description": "Extension fields. Names start with x- and are ignored by consumers that do not know them."
    }
  },
  "additionalProperties": false,
  "allOf": [
    {
      "$comment": "UN R129: height range and i-Size flag.",
      "if": {
        "properties": {
          "approvalRegulation": {
            "const": "UN R129"
          }
        },
        "required": ["approvalRegulation"]
      },
      "then": {
        "required": ["childHeightCm", "iSize"]
      }
    },
    {
      "$comment": "UN R44: weight groups and weight range.",
      "if": {
        "properties": {
          "approvalRegulation": {
            "const": "UN R44"
          }
        },
        "required": ["approvalRegulation"]
      },
      "then": {
        "required": ["weightGroups", "childWeightKg"]
      }
    },
    {
      "$comment": "Seats for both directions give their limits per direction.",
      "if": {
        "properties": {
          "orientation": {
            "const": "both"
          }
        },
        "required": ["orientation"]
      },
      "then": {
        "required": ["orientationRanges"]
      }
    },
    {
      "if": {
        "properties": {
          "vehicleTypeApproval": {
            "const": "specific-vehicle"
          }
        },
        "required": ["vehicleTypeApproval"]
      },
      "then": {
        "required": ["vehicleListUrl"]
      }
    }
  ]
}
