{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Creator card 1.0 / 1.1",
  "description": "Public creator-supplied card. Schema validity does not prove identity or ownership.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "canonical_url",
    "name",
    "handle",
    "headline",
    "bio",
    "location",
    "topics",
    "languages",
    "accounts",
    "work",
    "opportunities",
    "availability",
    "minimum_budget",
    "contact",
    "updated_at",
    "provenance"
  ],
  "properties": {
    "schema_version": {
      "enum": ["1.0", "1.1"]
    },
    "canonical_url": {
      "type": "string",
      "format": "uri",
      "pattern": "^(https://|http://(localhost|127\\.0\\.0\\.1|\\[::1\\])(:[0-9]+)?/)"
    },
    "name": {
      "type": "string",
      "minLength": 2,
      "maxLength": 80
    },
    "handle": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]{2,39}$"
    },
    "headline": {
      "type": "string",
      "minLength": 5,
      "maxLength": 140
    },
    "bio": {
      "type": "string",
      "minLength": 0,
      "maxLength": 2000
    },
    "location": {
      "type": "string",
      "minLength": 0,
      "maxLength": 100
    },
    "topics": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 50
      },
      "minItems": 1,
      "maxItems": 8
    },
    "languages": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 50
      },
      "minItems": 1,
      "maxItems": 6
    },
    "accounts": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 500,
        "format": "uri",
        "pattern": "^https://"
      },
      "minItems": 0,
      "maxItems": 6
    },
    "work": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 500,
        "format": "uri",
        "pattern": "^https://"
      },
      "minItems": 0,
      "maxItems": 6
    },
    "opportunities": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 80
      },
      "minItems": 1,
      "maxItems": 8
    },
    "availability": {
      "enum": ["open", "paused"]
    },
    "minimum_budget": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["amount", "currency"],
          "properties": {
            "amount": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000
            },
            "currency": {
              "enum": ["EUR", "USD", "GBP"]
            }
          }
        }
      ]
    },
    "contact": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["url", "method", "sign_in_required"],
          "properties": {
            "url": {
              "type": "string",
              "format": "uri",
              "pattern": "^(https://|http://(localhost|127\\.0\\.0\\.1|\\[::1\\])(:[0-9]+)?/)"
            },
            "method": {
              "const": "offer-form"
            },
            "sign_in_required": {
              "const": true
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["url", "method", "sign_in_required"],
          "properties": {
            "url": {
              "type": "string",
              "format": "uri",
              "pattern": "^https://"
            },
            "method": {
              "const": "external-link"
            },
            "sign_in_required": {
              "const": false
            }
          }
        }
      ]
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "provenance": {
      "type": "object",
      "additionalProperties": false,
      "required": ["source", "identity_verified", "account_ownership_verified"],
      "properties": {
        "source": {
          "const": "creator-supplied"
        },
        "identity_verified": {
          "const": false
        },
        "account_ownership_verified": {
          "const": false
        }
      }
    },
    "work_samples": {
      "type": "array",
      "maxItems": 6,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["url", "title", "image"],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://",
            "maxLength": 500
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "image": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri",
                "pattern": "^https://",
                "maxLength": 500
              },
              {
                "const": ""
              }
            ]
          }
        }
      }
    },
    "audience": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "platform",
            "size",
            "typical_views",
            "geography",
            "as_of",
            "source_url",
            "provenance"
          ],
          "properties": {
            "platform": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80
            },
            "size": {
              "anyOf": [
                {
                  "type": "null"
                },
                {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 10000000000
                }
              ]
            },
            "typical_views": {
              "anyOf": [
                {
                  "type": "null"
                },
                {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 10000000000
                }
              ]
            },
            "geography": {
              "type": "string",
              "maxLength": 120
            },
            "as_of": {
              "type": "string",
              "format": "date"
            },
            "source_url": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uri",
                  "pattern": "^https://",
                  "maxLength": 500
                },
                {
                  "const": ""
                }
              ]
            },
            "provenance": {
              "const": "creator-supplied"
            }
          }
        }
      ]
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "schema_version": {
            "const": "1.1"
          }
        }
      },
      "then": {
        "required": ["work_samples", "audience"]
      },
      "else": {
        "not": {
          "anyOf": [
            {
              "required": ["work_samples"]
            },
            {
              "required": ["audience"]
            }
          ]
        },
        "properties": {
          "contact": {
            "type": "object",
            "additionalProperties": false,
            "required": ["url", "method", "sign_in_required"],
            "properties": {
              "url": {
                "type": "string",
                "format": "uri",
                "pattern": "^(https://|http://(localhost|127\\.0\\.0\\.1|\\[::1\\])(:[0-9]+)?/)"
              },
              "method": {
                "const": "offer-form"
              },
              "sign_in_required": {
                "const": true
              }
            }
          }
        }
      }
    }
  ]
}
