{
  "$id": "https://feitoemportugal.org/api/v1/schema.json",
  "title": "Feito em Portugal — brand",
  "description": "A single brand file from data/brands/<slug>.yaml. Cross-field rules that JSON Schema cannot express are checked by the project validator.",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "slug": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "status": {
      "default": "draft",
      "type": "string",
      "enum": [
        "draft",
        "published"
      ]
    },
    "name": {
      "type": "string",
      "minLength": 2,
      "maxLength": 120
    },
    "description": {
      "type": "object",
      "properties": {
        "pt": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        "en": {
          "type": "string",
          "maxLength": 2000
        }
      },
      "required": [
        "pt"
      ]
    },
    "website": {
      "type": "string",
      "maxLength": 2000,
      "format": "uri"
    },
    "category": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "subcategory": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "tags": {
      "default": [],
      "maxItems": 20,
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
      }
    },
    "production": {
      "type": "object",
      "properties": {
        "scope": {
          "type": "string",
          "enum": [
            "total",
            "parcial"
          ]
        },
        "notes": {
          "type": "object",
          "properties": {
            "pt": {
              "type": "string",
              "maxLength": 2000
            },
            "en": {
              "type": "string",
              "maxLength": 2000
            }
          }
        }
      },
      "required": [
        "scope"
      ]
    },
    "location": {
      "type": "object",
      "properties": {
        "district": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "municipality": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        }
      },
      "required": [
        "district"
      ]
    },
    "price_range": {
      "type": "integer",
      "minimum": 1,
      "maximum": 4
    },
    "where_to_buy": {
      "type": "object",
      "properties": {
        "online_store": {
          "type": "string",
          "maxLength": 2000,
          "format": "uri"
        },
        "marketplaces": {
          "default": [],
          "maxItems": 10,
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 2000,
            "format": "uri"
          }
        },
        "physical_stores": {
          "maxItems": 50,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              },
              "city": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              },
              "url": {
                "type": "string",
                "maxLength": 2000,
                "format": "uri"
              }
            },
            "required": [
              "name",
              "city"
            ]
          }
        }
      }
    },
    "social": {
      "type": "object",
      "properties": {
        "instagram": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "facebook": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "tiktok": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "linkedin": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "pinterest": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "youtube": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        }
      }
    },
    "media": {
      "type": "object",
      "properties": {
        "logo": {
          "type": "string",
          "maxLength": 2000
        },
        "photos": {
          "default": [],
          "maxItems": 4,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "sustainability": {
      "type": "object",
      "properties": {
        "practices": {
          "default": [],
          "maxItems": 20,
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          }
        },
        "certifications": {
          "maxItems": 20,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
              },
              "proof_url": {
                "type": "string",
                "maxLength": 2000,
                "format": "uri"
              }
            },
            "required": [
              "id"
            ]
          }
        },
        "notes": {
          "type": "object",
          "properties": {
            "pt": {
              "type": "string",
              "maxLength": 2000
            },
            "en": {
              "type": "string",
              "maxLength": 2000
            }
          }
        }
      }
    },
    "verification": {
      "type": "object",
      "properties": {
        "verified": {
          "default": false,
          "type": "boolean"
        },
        "date": {
          "anyOf": [
            {
              "type": "string",
              "format": "date",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
            },
            {
              "type": "null"
            }
          ]
        },
        "method": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 2000
            },
            {
              "type": "null"
            }
          ]
        },
        "evidence_notes": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 2000
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "meta": {
      "type": "object",
      "properties": {
        "added": {
          "type": "string",
          "format": "date",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
        },
        "updated": {
          "type": "string",
          "format": "date",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
        },
        "source": {
          "type": "string",
          "enum": [
            "github",
            "web-form",
            "maintainer",
            "import",
            "outreach"
          ]
        }
      },
      "required": [
        "added",
        "updated",
        "source"
      ]
    }
  },
  "required": [
    "slug",
    "name",
    "description",
    "website",
    "category",
    "production",
    "meta"
  ]
}
