{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://product-information-graph.org/schema/2026-02-18/jsonld/Property.json",
  "title": "PIG Property JSON-LD Schema",
  "description": "Validates Property class definitions that specify attributes for entities and relationships. May include datatype specifications (string, integer, double, boolean, dateTime, etc.), cardinality constraints (sh:minCount, sh:maxCount, value constraints (sh:minInclusive, sh:maxInclusive, sh:maxLength, sh:pattern), enumeration values (pig:eligibleValue), default values, measurement units, and support for composed properties.",
  "type": "object",
  "properties": {
    "@id": {
      "$ref": "#/$defs/idString"
    },
    "@type": {
      "$ref": "#/$defs/idString"
    },
    "pig:specializes": {
      "$ref": "#/$defs/idObject"
    },
    "pig:itemType": {
      "type": "object",
      "required": [
        "@id"
      ],
      "properties": {
        "@id": {
          "type": "string",
          "enum": [
            "pig:Property"
          ],
          "description": "The PigItemType for pig:Property"
        }
      },
      "additionalProperties": false
    },
    "dcterms:title": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/languageValue"
      }
    },
    "dcterms:description": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/languageValue"
      }
    },
    "sh:datatype": {
      "$ref": "#/$defs/idObject"
    },
    "sh:minCount": {
      "type": "integer",
      "minimum": 0
    },
    "sh:maxCount": {
      "type": "integer",
      "minimum": 1
    },
    "sh:maxLength": {
      "type": "integer",
      "minimum": 1
    },
    "sh:minInclusive": {
      "type": "number"
    },
    "sh:maxInclusive": {
      "type": "number"
    },
    "sh:pattern": {
      "type": "string",
      "description": "Regular expression pattern for string validation"
    },
    "pig:unit": {
      "type": "string",
      "description": "Unit of measurement (SI unit)"
    },
    "sh:defaultValue": {
      "type": "string",
      "description": "Default value for this property"
    },
    "pig:eligibleValue": {
      "type": "array",
      "description": "Enumeration of allowed values",
      "items": {
        "oneOf": [
          {
            "type": "object",
            "description": "Enumeration value with multi-language title (for xs:string)",
            "properties": {
              "@id": {
                "type": "string",
                "description": "Unique identifier for this enumeration value",
                "pattern": "^(?:[A-Za-z0-9_\\-]+:[^:\\s]+|https?:\\/\\/[^\\s]+)$"
              },
              "dcterms:title": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "object",
                  "properties": {
                    "@value": {
                      "type": "string",
                      "minLength": 1
                    },
                    "@language": {
                      "type": "string"
                    }
                  },
                  "required": [ "@value" ],
                  "additionalProperties": false
                },
                "description": "Multi-language title for string enumerations"
              }
            },
            "required": [ "@id", "dcterms:title" ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "Enumeration value with literal value (for xs:integer, xs:double, etc.)",
            "properties": {
              "@id": {
                "type": "string",
                "description": "Unique identifier for this enumeration value",
                "pattern": "^(?:[A-Za-z0-9_\\-]+:[^:\\s]+|https?:\\/\\/[^\\s]+)$"
              },
              "@value": {
                "type": "string",
                "minLength": 1,
                "description": "Literal value for numeric and other datatypes (stored as string)"
              }
            },
            "required": [ "@id", "@value" ],
            "additionalProperties": false
          }
        ]
      }
    },
    "pig:composedProperty": {
      "type": "array",
      "description": "References to other properties that compose this property",
      "items": {
        "$ref": "#/$defs/idObject"
      }
    }
  },
  "required": [
    "@id",
    "pig:itemType",
    "dcterms:title",
    "sh:datatype"
  ],
  "oneOf": [
    {
      "required": [
        "@type"
      ]
    },
    {
      "required": [
        "pig:specializes"
      ]
    }
  ],
  "additionalProperties": false,
  "$defs": {
    "idString": {
      "type": "string",
      "pattern": "^(?:[A-Za-z0-9_\\-]+:[^:\\s]+|https?:\\/\\/[^\\s]+)$",
      "description": "A valid ID string: either a namespaced identifier (prefix:name) or a URL"
    },
    "idObject": {
      "type": "object",
      "required": [
        "@id"
      ],
      "properties": {
        "@id": {
          "$ref": "#/$defs/idString"
        }
      },
      "additionalProperties": false,
      "description": "JSON-LD ID object wrapper"
    },
    "languageValue": {
      "type": "object",
      "required": [
        "@value"
      ],
      "properties": {
        "@value": {
          "type": "string",
          "minLength": 1,
          "description": "The actual text content"
        },
        "@language": {
          "type": "string",
          "pattern": "^[a-z]{2}(-[A-Z]{2})?$",
          "description": "IETF language tag (e.g., 'en', 'de', 'en-US')"
        }
      },
      "additionalProperties": false,
      "description": "Multi-language text value with optional language tag"
    }
  }
}
